17

I'm using this code for showing an image in landscape mode:

\begin{landscape}

\begin{figure}[H]
\centering
\includegraphics[width=\hsize]{./images/SelectDVA.png}
\caption{DVA part of the Use Case \ref{sec:use_case_2}.}
\end{figure}

\end{landscape}

This causes the output to have a blank page immediately after the rotated page containing the image.

It seems that using landscape causes a page break, is it true?

How can I prevent this behaviour?

Matteo
  • 1,787

6 Answers6

14

landscape will not produce blank pages but cause a page break where it is introduced. This will result in undesired white space in the previous page. This can be avoided by using the afterpage package:

\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{afterpage}
\usepackage{lscape}
\begin{document}
\lipsum[1-2]
\afterpage{
\begin{landscape}

\begin{figure}[H]
\centering
\includegraphics[width=\hsize]{example-image-a}
\caption{DVA part of the Use Case \ref{sec:use_case_2}.}
\end{figure}

\end{landscape}
}
\lipsum[3-8]

\end{document}

If you use pdflscape instead of lscape package,

enter image description here

  • can you explain me what is the \lipsum command doing?thks in advance – Matteo Nov 27 '12 at 15:59
  • @Matteo It's just filler http://en.wikipedia.org/wiki/Lipsum – David Carlisle Nov 27 '12 at 16:53
  • 2
    This isn't working for me. I still have a blank page before the landscape figure. The code was used exactly as in the example above, except that I am using package 'pdflscape'. – cryptic0 May 19 '14 at 11:17
  • @cryptic0 Not working isn't useful enough. This code works for me. –  May 19 '14 at 22:28
  • I am using this code for a landscape figure. The only change I have made is using pdflscape package which actually rotates the page to landscape mode. However, there is still a blank page before every landscape figure. – cryptic0 May 20 '14 at 01:56
  • @cryptic0 See what I get above with pdflscape. That is why the above comment :) –  May 20 '14 at 01:59
  • There must be some other package that is interfering in my case then. I will investigate. – cryptic0 May 20 '14 at 14:22
  • 4
    The problem is related to the size of the figure. Even if it fits on one page, it might still result in a blank page. I scaled down the figure gradually until the blank page went away. FYI. – cryptic0 May 21 '14 at 21:04
13

A blank page can be caused by the figure (or table, etc) within the landscape environment exceeding the dimensions of the page's textwidth or textheight. In this case, we can manually define the page margins with \newgeometry{} and then revert back to the document default with\restoregeometry. For example:

\documentclass{article}
\usepackage{geometry}
\usepackage{lscape}
\begin{document}

% Set some new page margins:
\newgeometry{a4paper,left=1in,right=1in,top=1in,bottom=1in,nohead}
\begin{landscape}
     % figure, etc
\end{landscape}
\restoregeometry % Restore the global document page margins

\end{document}

Or you can do it with \savegeometry{name} and \loadgeometry{name}. See http://texdoc.net/texmf-dist/doc/latex/geometry/geometry.pdf

pds
  • 261
  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. – Pier Paolo Jan 18 '15 at 21:43
  • 7
    Thanks for your comment @PierPaolo. I have read the article countless times, but for the life of me I don't understand which specific policy you and your upvoter believe I have not followed. Please explain. – pds Apr 03 '15 at 14:08
  • I tried this and it generated an additional blank page! – Dan Fox Sep 28 '22 at 07:38
8

Have you checked this simple solution? I had a big, page-filling table and the landscape environment caused a blank page before the table. I noticed that the option [H] in \begin{table}[H] caused the blank page. If you use \begin{table}[htbp] instead, the annoying blank page is gone. [H] is useful to place the tables exactly where you position the command, but in conjunction with the landscape environment it is unnecessary.

Example:

\usepackage{lscape}

\begin{document}    
% some text    
\begin{landscape}    
\thispagestyle{empty} %if you want to suppress footer and header    
\begin{table}[htbp]    
...    
\end{table}    
\end{landscape}    
% continue with your text    
\end{document}
Adam Liter
  • 12,567
Pof8
  • 81
  • 1
    Welcome to TeX.SX! A tip: If you indent lines by 4 spaces or [enclose words in backticks ```](http://meta.tex.stackexchange.com/q/863), they'll be marked as code, as can be seen in my edit. You can also highlight the code and click the "code" button (with "{}" on it). – Adam Liter Jul 02 '14 at 01:56
  • To rotate pages with \usepackage{pdflscape} or \usepackage{lscape} in a document generated with bookdown/R markdown, this was the only viable solution that worked for me. I.e., adding fig.pos = 'htbp' to the chunk header of my figure made the obsolete blank white landscape page before the landscape page with the figure magically disappear. – mavericks Dec 29 '20 at 12:01
5

Another simple solution is turn 90° the content of a normal float (without [H]) using only normal (portrait) pages:

\documentclass[12pt]{article}
\usepackage{lipsum}
\usepackage{graphicx}
\begin{document}
\lipsum[1-2]
\begin{figure}
\rotatebox{90}{
\begin{minipage}{\textheight}
\includegraphics[width=\linewidth]{example-image-a}
\caption{DVA part of the Use Case.}
\end{minipage}}
\end{figure}
\lipsum[3-7]
\end{document}

MWE

Fran
  • 80,769
0

I have exactly the same problem as you. I have a landscape environment followed by a figure environment. The landscape environment introduces a blank page between the landscape environment and the figure environment. I solve this issue by accidentally changing \begin{figure} to \begin{figure}[H]. Have no idea why ...... but it works! I got the idea from this post: How to remove a blank page before landscape figure tabular? where they said removing [H] works, but for me adding [H] works.

0

I like this answer's approach of simply minimizing page margins. However, I am using KOMAScript and the geometry package doesn't seem to work well with it (as far as I know!). Thus, here's a hopefully KOMAScript-idiomatic way that worked for me:

\documentclass{scrbook}
\usepackage{lscape}

\AtBeginDocument{% \storeareas\normalpapersize% } \BeforeRestoreareas{\cleardoublepage}

\begin{document}

% set some new page margins \KOMAoptions{DIV=16} \recalctypearea \begin{landscape} % figure, etc \end{landscape} \normalpapersize

\end{document}

ComFreek
  • 1,248
  • 2
  • 15
  • 22