2

I want to have an image that fills a landscape page.

I have tried:

\documentclass[a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage{pdflscape} %Gives us landscape pages with begin{landscape}. Use this for pages with very large diagrams.
\usepackage{geometry} %change margin on individual page \newgeometry{} and \restoreometry
\usepackage{graphicx}
\usepackage{caption} %nicer captions
\usepackage{float}%exact placement of floats (things inside a begin{})

\usepackage{todonotes}  %For the minium working example

\begin{document}

\listoffigures

\begin{landscape}

  \newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
  \thispagestyle{empty} %disable page numbering for this page

    \vfill
      \begin{center}
        \begin{figure}
          \missingfigure[figwidth = \paperwidth]{picture}
          \label{label32}
          \caption{a big image}
        \end{figure}
      \end{center}
    \vfill

  \restoregeometry
\end{landscape}

\end{document}

But this places the image in the top right corner of the landscape page, and its not even scaled that big. If I use \centering inside the figure environment instead of creating a center environment, the figure is then put in the bottom corner.

How can I place it so that it is horizontally and vertically centered, and it fills the page, with about a 1 or 2 cm margin?

These requirements are all flexible if you have a better suggestion. My main goal is to display an image with lots of fine detail, only visible when it scaled up to just less than A4 size.

I am using the pdflatex compiler, and hence I am using the pdflscape package. My document type is a report, and cannot be changed.

Preview:

enter image description here

  • 1
    Don’t use the figure environment, to begin with: it is meant for creating floating insertions, which is not what you want. Before answering, I would like to see a Minimal Working Example, complete from \documentclass to \end{document}. – GuM Jun 12 '15 at 21:40
  • @GustavoMezzetti I've edited the question so that it includes a minimal working example. I've also included packages that may effect the solution. – Blue7 Jun 12 '15 at 22:09
  • Also, do I not have to use the figure environment so that it numbers correctly, and so I can add a caption to it? It also needs to appear in the list of figures. – Blue7 Jun 12 '15 at 22:15
  • 1
    Sorry, I did’t see your edit before posting my answer: I’ll try to see if I have still got time to examine your code. EDIT: I understand now that you do want a figure. – GuM Jun 12 '15 at 22:19
2

Building on Gustavo Mezzetti's answer, the image can be placed in a figure environment so it can be captioned and listed in the \listoffigures. A few other modifications are required, shown below.

The \paperheight adjustment (-6cm) needs to be manually tuned depending on the aspect ratio of your image. This is best done by eye anyway, as an automatic process wouldn't know what looks best.

\documentclass[a4paper]{report}

\usepackage[utf8]{inputenc}
\usepackage{pdflscape} %Gives us landscape pages with begin{landscape}. Use this for pages with very large diagrams.
\usepackage{geometry} %change margin on individual page \newgeometry{} and \restoreometry
\usepackage{graphicx}
\usepackage{caption} %nicer captions
\usepackage{float}%exact placement of floats (things inside a begin{})
\usepackage{mwe}


\begin{document}

\listoffigures

\newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}

\begin{landscape}
  \thispagestyle{empty} %disable page numbering for this page
        \begin{figure}
           \centering
           \includegraphics [width=\dimexpr\paperheight-6cm\relax]{image}
          \label{label32}
          \caption{a big image}
        \end{figure}
\end{landscape}

\restoregeometry

\end{document}

Preview:

enter image description here

Addition:

Here it is as a command. Put this in the document preamble:

%Command to insert a landscape page filled with a centred figure.
%The arguments are: {marginsize}{tunable parameter to adjust for aspect ratio}{caption}{imagepath}
%Example usage: \hFigure{1cm}{2cm}{This is a big image}{pics/myImage.png}
\newcommand{\hFigure}[4]{
\newgeometry{left=#1,right=#1,top=#1,bottom=#1}
\begin{landscape}
  \thispagestyle{empty} %disable page numbering for this page
\vfill
        \begin{figure}
           \centering
           \includegraphics [width=\dimexpr\paperheight-#2\relax]{#4}
          \label{label32}
          \caption{#3}
        \end{figure}
\vfill
\end{landscape}
\restoregeometry
}
  • 1
    Very good, I’m going to upvote! :-) Are you interested in seeing the code I worked out in the meanwhile? Then, I must really go. – GuM Jun 12 '15 at 22:59
2

I am not completely sure of what you want to achieve and what limitations you have got, but, to begin with, you might want to have a look at the following code:

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{pdflscape}
\usepackage{mwe} % for sample figures -- automatically loads graphicx

\begin{document}

Preceding stuff.

\newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\thispagestyle{empty}
\begin{landscape}
    \vspace*{\fill}
    \noindent\begin{minipage}[c][0pt][c]{\columnwidth}
        \centerline{%
            \includegraphics
                [width=\dimexpr\paperheight-2cm\relax]
                {image}%
        }
    \end{minipage}
    \vspace*{\fill}
\end{landscape}
\restoregeometry

Subsequent stuff.

\end{document}

Notice that \paperheight remains \paperheight even in landscape orientation. I (or other people, since I must disconnect, now) will make further adjustments if thi is not exactly what you want.

Addition

It turned out that the OP wants to caption the figure: this can be done within the minipage environment itself by means of \captionof command from the caption package. Recourse to a floating figure environment is best avoided, in my opinion, since the geometry and page style settings wouldn’t be very robust (what if other preceding floats were waiting to be placed on a page themselves?).

Here is the updated code:

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{caption}
\usepackage{pdflscape}
\usepackage{mwe}

\begin{document}

\listoffigures
\bigbreak

Preceding stuff.

\newgeometry{left=1cm,right=1cm,top=1cm,bottom=1cm}
\thispagestyle{empty}
\begin{landscape}
    \vspace*{\fill}
    \noindent\begin{minipage}[c][0pt][c]{\columnwidth}
        \centerline{%
            \includegraphics[
                        width=\dimexpr\paperheight-2cm\relax,
                        height=10cm % assuming your image is short enough that 
                                    % it does not overprint the caption
                    ]{image}%
        }
        \centering
        \captionof{figure}{A nice figure}
        \label{fig:label}
    \end{minipage}
    \vspace*{\fill}
\end{landscape}
\restoregeometry

Subsequent stuff, with a reference to figure~\ref{fig:label}.

\end{document}

I am assuming that the image is not so tall that the caption is pushed off the page, of course.

  • This almost works, but I cannot caption it, and it does not appear in the list of figures. (See edited code in main question). Is there a way to fix this? – Blue7 Jun 12 '15 at 22:20
  • Found the answer. I'll post it as a new answer here now. – Blue7 Jun 12 '15 at 22:30
  • Thank you for the addition. I agree, using a floating figure environment could cause problems. Also, yes, my image is not tall, hence why I wanted it on a landscape page :). – Blue7 Jun 12 '15 at 23:29
  • @Blue7: Yet it is true that \newgeometry begins with \clearpage! But try, for instance, having some text in the landscape environment, alongside with the figure. – GuM Jun 13 '15 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.