3

I'm new to pdfLaTeX so i could be missing something very obvious, i have looked at a few solutions none of which have worked for me.

i have a figure which is a rather large image which needs to maintain is caption and fit with the page. The image fits onto a landscape a4 page, however not matter what i have tried thus far latex renders the image from the center of the page so the figure overflows the edge of the paper.

i assume its something to do with the fact that i am using 1 landscape page when the rest are portrait so it maybe an issue with margin configuration.

heres the corresponding snippet which contains the problem(ignore the caption):

\documentclass[10pt,a4paper]{article}
\usepackage[margin=1.2in]{geometry}
\usepackage{graphicx}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
    \begin{figure}[ht]
        \centering
        \label{fig:singleton}
        \includegraphics[scale=0.8]{class-diagram}
        \caption{Proposed high level implementation of the Singleton pattern}
    \end{figure}
\end{landscape}
\end{document}

I have scaled the image to 0.8 just so its more clear where the figure is being rendered.

This is the current output:

enter image description here

This is the desire outcome:

enter image description here

This is the image being used for the figure

Hopefully it is clear what the problem is.

3

Here is a solution. I use the measuredfigure environment, from threeparttable, to keep the caption centred with respect to the figure:

\documentclass[10pt,a4paper]{article}
\usepackage{ebgaramond}
\usepackage[margin=1.2in]{geometry}
\usepackage{graphicx}
\usepackage{pdflscape}
\usepackage{caption}
\captionsetup{labelfont = sc, textfont = it}
\usepackage{threeparttable}

\begin{document}

\begin{landscape}
\mbox{}\vfill
\begin{figure}[ht]
        \label{fig:singleton}
\begin{measuredfigure}
        \includegraphics[scale = 0.5]{Piero_di_Cosimo_2}
        \caption{ And now for something completely different! }
\end{measuredfigure}
    \end{figure}
\vfill\mbox{}
\end{landscape}

\end{document} 

enter image description here

1
  • thank you. Im going to research some of the new commands you have shown me so i know exactly what they do. Just need to toy with the image size a bit to make it optimal. – chris edwards Feb 14 '15 at 20:31
1

There's no real need for anything special here:

enter image description here

\documentclass{article}
\usepackage[margin=1.2in]{geometry}
\usepackage{graphicx,pdflscape,lipsum,caption}
\begin{document}

\lipsum[1-5]

\begin{landscape}
  \centering
  \includegraphics[scale=1.3]{example-image}
  \captionof{figure}{Some caption associated with the picture}
  \label{fig:singleton}
\end{landscape}

\lipsum[1-5]
\end{document}

Since the landscape environment forms a group, you can use \captionof{figure}{...} to place a traditional figure caption without the use of the figure environment. The reason for avoiding the figure environment is because you don't want the content to float (away).

Also, always place the \label after the \caption; see Why does an environment's label have to appear after the caption?

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.