Tag Archives: landscape

Rotate an image, table or paragraph in LaTeX

The rotating package provides easy-to-use functionality to rotate content. The float environments sidewaystable and sidewaysfigure introduce landscape tables and figures, respectively. The package automatically takes care of the rotation direction for twoside documents. Besides 90 degrees rotation, the package also provides a command and environment to rotate content at an arbitrary angle.

Sidewaysfigure example

The easiest way to take full advantage of the page and position a figure (or table) in landscape-form is through the rotating package.

\documentclass[11pt]{article}
\usepackage{rotating, graphicx}
\begin{document}
\begin{sidewaysfigure}
\includegraphics[width=\textwidth]{capsules}
\caption{Result of a long day  at work.}
\end{sidewaysfigure}
\end{document}

I manually rotated the page to better fit here. Sidewaysfigure will place the figure on a separate page, as will sidewaystable.

Arbitrary angle text example

The command turn allows rotation at an arbitrary angle in degrees. Here is a rather useless example, but you get the idea:

\documentclass[11pt]{article}
\usepackage{blindtext, rotating}
\begin{document}
\begin{turn}{45}
\begin{minipage}{\linewidth}
\blindtext
\end{minipage}
\end{turn}
\blindtext
\end{document}

I use the minipage environment to limit the text horizontally. Otherwise, the entire paragraph is printed on a single line. The picture below is a snapshot of the output.

Did you come across an awesome package or would like me to write about a particular topic? Get in touch.

LaTeX documentclass options illustrated

The three most commonly used standard document-classes in LaTeX include: article, report and book. A number of global options allows customization of certain elements of the document by the author. Different document-classes might have different default settings. The following post illustrates available options with figures, provides alternatives and highlights the default option for each document-class.

To change the default behavior, the option is provided as an optional parameter to the documentclass command.

\documentclass[option1, option2, etc.]{article}

• Font size (10pt, 11pt, 12pt)
• Paper size and format (a4paper, letterpaper, etc.)
• Draft mode (draft)
• Multiple columns (onecolumn, twocolumn)
• Formula-specific options (fleqn and leqno)
• Landscape print mode (landscape)
• Single- and double-sided documents (onepage, twopage)
• Titlepage behavior (notitlepage, titlepage)
• Chapter opening page (openright, openany)
•

Font size

LaTeX knows three standard font sizes:

• 10pt (default)
• 11pt
• 12pt

Other global and local font sizes are available through various packages.

The following example sets the global document font size to 12pt. The picture below compares the three LaTeX standard font sizes.

\documentclass[12pt]{article}
\usepackage{blindtext}
\begin{document}
\blindtext
\end{document}

Paper size and format

Different regions of the world use different standard physical paper sizes. Available are:

• a4paper (default)
• letterpaper (default in some distributions)
• a5paper
• b5paper
• executivepaper
• legalpaper

The following example compares (from left to right): legal, A4, Letter and A5.

\documentclass[a4paper]{article}
\usepackage{showframe}
\begin{document}
\begin{center}{\Huge A4 paper}\end{center}
\end{document}

The geometry package provides similar options and additional flexibility for paper size and margins.

Draft mode

Setting the draft option will speed up typesetting, because figures are not loaded, just indicated by a frame. LaTeX will also display hyphenation (Overfull hbox warning) and justification problems with a small black square. Delete the draft option or replace it with final in the final document version.

Multiple columns
• onecolumn (default)
• twocolumn

By default, text is typeset in a single column (onecolumn). LaTeX provides an easy way to switch to two columns through the document-class option twocolumn.

The multicol package allows creating more than two columns globally as well as locally.

Formula-specific options
• fleqn: left-alignment of formulas
• leqno: labels formulas on the left-hand side instead of right

These are two independent options manipulating the alignment and label position of formulas.

The top figure illustrates the default case with neither option set. The bottom figure shows how formulas are typeset when both options, fleqn and leqno, are set.

Landscape print mode

The landscape option changes the page layout to landscape mode. This, however, does not change the page margins accordingly (first page in figure), which is why for landscape documents with landscape content the pdflscape or geometry packages (second page in figure and code) are more suitable.

\documentclass[a4paper]{article}
\usepackage{blindtext, showframe}
\usepackage[landscape]{geometry}
\begin{document}
\blindtext
\end{document}

Single- and double-sided documents
• oneside (default for article and report)
• twoside (default for book)

In single-sided documents (oneside), the left and right margins are symmetric and headers are exactly the same on every page. In other words, the document does not distinguish between inner and outer margin. Twoside, on the other hand, generates double-sided content. The outer margin (even page: left; odd page: right) is wider by default (see figure below). It might appear that the header “switches” sides, but that because they are placed with respect to the margins. The twoside option is usually set for bound texts such as theses or books.

\documentclass[twoside]{report}
\usepackage{blindtext, showframe, fancyhdr}
\pagestyle{fancy}
\begin{document}
\chapter{First chapter}
\section{First section}
\blindtext
\clearpage
\Blindtext
\end{document}

Titlepage behavior
• notitlepage (default for article)
• titlepage (default for report and book)

The option titlepage ends the page after \maketitle and restarts on the next page. In article, the content starts right after \maketitle. The titlepage option is quivalent to:

\maketitle
\clearpage

The example below illustrates the default behavior of article.

\documentclass{article}
\usepackage{blindtext}
\title{This is an article}
\begin{document}
\maketitle
\begin{abstract}
\blindtext
\end{abstract}
\end{document}

Chapter opening page
• openany (default for report)
• openright (default for book)

Finally, the option openright always starts a chapter on the right (odd pages), leaving one page blank in case the last paragraph of the previous chapter ended on an odd page. It only works and makes sense with the twoside option set. The openany option starts the chapter on the next page (even or odd).

The openany, openright options are not available in article as it does not support \chapter!

\documentclass[twoside, openright]{report}
\usepackage{blindtext}
\begin{document}
\chapter{First chapter}
\blindtext
\chapter{Second chapter}
\blindtext
\end{document}

Printing multiple pages on one with pgfpages

Your operating system can print several pages on one. Sometimes however you may want to have the PDF showing several slides on a single page, e.g. for handouts of a presentation. On a Linux system, psnup/pdfnup are extremely flexible if you are familiar with these commands and their options. But it’s definitely faster and more convenient to do it from inside a LaTeX document using pgfpages with just two lines of code.

Example 1: Two on One

\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,border shrink=5mm]

Example 2: Four on One

\usepackage{pgfpages}
\pgfpagesuselayout{4 on 1}[a4paper,border shrink=5mm,landscape]

Some remarks:

• 2, 4, 8 and 16 on 1 are available (for resize to see below)
• The border shrink option provides some space between slides
• The landscape options is required depending on whether your pages are portrait/landscape.
\pgfpagesuselayout{resize to}[a4paper,border shrink=5mm]

Using resize to will resize any page to the selected page format (a4paper/letterpaper).

The package is quite limited in its functionality. However, since gpfpages is really easy to use and it’s a good choice in the most common situations.

Note, if you are using a table of contents, the page numbers may be wrong. To solve this issue, comment out the \pgfpagesuselayout{...}[...] command and typeset the document. This will set the page numbers right. Next you uncomment the line again and add a \nofiles command on a separate line. That will prevent Latex from overwriting “meta”-files and therefore leave the page numbers in your index untouched.

Save the planet using Latex, print 2in1!

I just found this very cool package which lets you easily print two pages in one. I have only tested it for articles and reports and it works perfectly for articles. Using the document-class report, the content is perfectly structured, but not the table of contents, which still takes the entire page. The package also messes up with the page numbers whenever you start a new chapter. So it basically only works with sections, but not chapters.

First tell Latex to turn the page to landscape:

\documentclass[a4paper, landscape]{article}

Next include the necessary packages:

\usepackage{2in1, lscape}

The latter is needed, as you not only want the paper layout, but also the content to be in “landscape-mode”.

Now add your document content and have fun printing (and saving the planet )!

The standard distributions have this package included, but just in case you can get it from here.

Landscape in Latex

The default page layout is “portrait”, but sometimes it is still useful/necessary to have the whole document or only single pages changed to “landscape”. The latter might be due to a large table or figure. This post will tell you how to change the page layout of the whole document or single pages to “landscape”. In addition, it is possible to make single pages appear left side up in the PDF, making them more readable.

Changing the whole document to “landscape” can be done be using the geometry-package:

\usepackage[landscape]{geometry}

You can also just change the page content to landscape, but not the actual page layout through the optional argument of the command “documentclass”. It does not make much sense, but you can do it:

\documentclass[landscape, 12pt]{report}

Next I will show you how to change the page layout of single pages. The lscape-package provides according possiblities:

\usepackage{lscape}

With

\begin{landscape}
...
\end{landscape}

you define the section of your document to be set to “landscape”, e.g. a large table or figure.

This will not automatically rotate the page in the PDF and is useful if the document is destined for printing.

If you want to make appear the left side up, better readable on screen, the pdflscape-package will do it:

\usepackage{pdflscape}

and again:

\begin{landscape}
...
\end{landscape}

for the page to be “landscape”, while the rest will remain in “portrait” orientation. Nevertheless, the header/footer will also be changed in orientation.