2

I have a figure with a note below (not a caption: "blah blah blah..." in the below MWE). I would like it to be directly below the figure, but currently there is far too much white space separating them.

The code I am currently running is below. I am using the minipage environment because the figure I am inserting is very large (it was generated in Stata, and I have tried saving it in multiple ways without luck). Is there a way to reduce the white space in this environment? I have already tried using \vspace as I do after the caption, and it doesn't work. Same for the caption package, \abovecaptionskip, etc. If someone could help, I would really appreciate it! Thanks in advance.

\documentclass[12pt]{article}

\begin{document}
\begin{figure}[h!] 
\begin{centering}
\begin{minipage}{0.95\textwidth} 
 \caption{My Title Here}\label{mylabel}
 \vspace*{-4cm} 
\includegraphics[height=8in]{figure.pdf}
{\footnotesize blah blah blah blah blah blah blah blah blah blah.\par}
\end{minipage}
\end{centering}
\end{figure}

\end{document}
  • 1
    the minipage and centering environments are doing nothing useful here you just want \centering at the start of the figure (which is already a minipage, essentially), and always leave a blank line before \vspace and before your note – David Carlisle Jun 19 '17 at 23:31
  • the test file produces ! Undefined control sequence. l.9 \includegraphics – David Carlisle Jun 19 '17 at 23:36
0

The root of the problem, I gues, is the white frame around the figure generated in Stata. If you crop the figure appropriately, it will fit easily on the page as the example below. The showframe option is just for testing, you can remove it later. Also, \vspace is not needed here as well as the minipage as @DavidCarlisle mentioned.

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[margin=1in,showframe]{geometry}
\begin{document}

\begin{figure}[h!] 
   \centering    
     \caption{My Title Here}\label{mylabel}

     %\vspace*{-4cm} 
     \includegraphics[height=8in,width=.95\textwidth]{example-image}

     {\footnotesize blah blah blah blah blah blah blah blah blah blah.\par}      
\end{figure}

\end{document}

enter image description here

  • Thanks @AboAmmar! As you suggested, cropping the figure appropriately was key. I added the trip and crop options to your code as follows, and it worked perfectly: \includegraphics[height=4in,width=.95\textwidth,trim=1cm 7cm 0 6cm, clip] – Y. Zeira Jun 20 '17 at 1:45
1

If I remove the spurious markup and add the missing package inclusion I get

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htp!] 
\centering



 \caption{My Title Here}\label{mylabel}

\includegraphics[height=8in,width=4in]{example-image}

\footnotesize blah blah blah blah blah blah blah blah blah blah.

\end{figure}

\end{document}

which produces

 LaTeX Warning: Float too large for page by 63.38252pt on input line 13.

so you need to lose almost an inch of space somewhere adding -64pt of negative space makes the warning go, but for you to judge whether it is acceptable to steal that much space from the top margin

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htp!] 
\centering

\vspace{-64pt}


 \caption{My Title Here}\label{mylabel}

\includegraphics[height=8in,width=4in]{example-image}

\footnotesize blah blah blah blah blah blah blah blah blah blah.

\end{figure}

\end{document}

enter image description here

  • Thanks very much, @David Carlisle. I used your code and was able to more or less replicate the figure you created. However, when I use my own figure instead of the example figure, I am still running into my original problem. Do you have any additional ideas I might try? – Y. Zeira Jun 20 '17 at 0:06
  • Just wanted to add that this code also works once the figure is cropped (see below). That was the real problem; once that was solved, multiple ways of coding the figure seem to get the job done. – Y. Zeira Jun 20 '17 at 1:51
0

Really is a good idea change the top margin in only one page to fit a big image? Use the package geometry with showframe option to see where the margins should be. If you need a really big image change the margins consistently (in all the document) but please do not ruin the document layout with a negative \vspace.

But, most probably you can reduce a pinch the image without any noticeble loss of resolution. Any image, independently of their original height and width, will be scaled as far as possible until fit to fill all the horizontal or all the vertical space, without invade the margins, with these options:

height=\textheight,width=\linewidth,keepaspectratio

If you need also two lines of text, is as simple as reduce the height a bit (for instance .95\textheight, to left roughly 32pt for the caption and the footnote in this example:

mwe

\documentclass[12pt]{article}
\usepackage[margin=1in,showframe]{geometry}
\usepackage{graphicx}
\begin{document}
\begin{figure}[htp!]
\abovecaptionskip0pt
\caption{My Title Here}
\centering
\includegraphics%
[height=.95\textheight,width=\linewidth,keepaspectratio]%
{example-image-10x16}\par\footnotesize 
blah blah blah blah blah blah blah blah blah blah.
\end{figure}
\end{document}

Note: As your MWE insert a \vspace*{-4cm} between the caption and the image, I guess that you have a image with a big empty space. The right solution in this case is crop the original image with a external tool, as Gimp, or use the trim and clip options in \includegraphics. See How to crop background from image automatically?

  • Thanks, @Fran! You are right - the key was to crop the original image, which I did using the trim and clip options in \includegraphics as you suggested. I added those options to your code as follows: \includegraphics[height=.95\textheight, width=6in, keepaspectratio, trim=1cm 7cm 0 6cm, clip] – Y. Zeira Jun 20 '17 at 1:40

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.