4

I'm trying to fit two over-sized figures side by side on one page. I tried using minipage and adjustwidth, but the caption on the second figure kept mis-aligning to the left, as shown below.

I tried reading multiple seemingly related questions, but I wasn't able to figure this out. I tried using subfigure following one of the suggestions, but that seemed to do worse.

Any tips would be appreciated. Thanks.

\documentclass{article} % letter paper and 11pt font 
\usepackage[space]{grffile} % for filenames with spaces
\usepackage{float} 
\usepackage{graphicx} 
\usepackage{chngpage}
\usepackage{caption}
\usepackage{calc}
\begin{document}

\begin{minipage}[t]{.5\textwidth}     % example that almost works
        \begin{figure}[H] 
            \begin{adjustwidth}{-\oddsidemargin-1in}{-\rightmargin}
            \centering 
            \caption{Schooling Time Shares}
            \includegraphics[scale=0.5]{Schooling Time Share over Time.png} 
            \end{adjustwidth}
    \end{figure}
\end{minipage}% 
\begin{minipage}[t]{.5\textwidth}
        \begin{figure}[H] 
            \begin{adjustwidth}{\oddsidemargin-0.8in}{-\rightmargin}
            \centering 
            \caption{Training Time Shares}
            \includegraphics[scale=0.5]{Training Time Share over Time.png} 
            \end{adjustwidth}
        \end{figure}
\end{minipage}

\end{document}

timeshares

Update: After Mico's expert suggestions, I tried the following:

\begin{figure}[ht!] 
\begin{adjustwidth}{-1.85cm}{-1.75cm}  % choose margin adjustments
\begin{minipage}{0.48\linewidth}
\caption{Schooling Time Shares}
\includegraphics[scale=0.5]{Schooling Time Share over Time.png} 
\end{minipage}
\hspace*{\fill}  % spread out the two minipages
\begin{minipage}{0.48\linewidth}
\caption{Training Time Shares}
\includegraphics[scale=0.5]{Training Time Share over Time.png}
\end{minipage} 
\end{adjustwidth}
\end{figure}

which produced the following output:

timeshares2

Now the captions are symmetric, which is much better than before. One last remaining bit, though, is: If one (perhaps unnecessarily) wanted to make the captions come more closely to the center, how could one do this? I thought maybe I could introduce a few spaces next to the caption, but an hspace* or mbox only shifted the caption down, not to the right.

Update2: As commented below \caption{\kern0.2cm Schooling Time Shares} is able to move the caption text slightly to the right. Also width=1.1\linewidth is more stable than scale=0.5. Final code:

\begin{figure}[ht!] 
\begin{adjustwidth}{-3.5cm}{-3cm}  % choose margin adjustments
\begin{minipage}{0.48\linewidth}
 \caption{\kern0.2cm Schooling Time Shares }
\includegraphics[width=1.1\linewidth]{Schooling Time Share over Time.png} 
\end{minipage}
\hspace*{\fill}  % spread out the two minipages
\begin{minipage}{0.48\linewidth}
\caption{\kern0.2cm Training Time Shares }
\includegraphics[width=1.1\linewidth]{Training Time Share over Time.png}
\end{minipage} 
\end{adjustwidth}
\end{figure}

produces

timeshares3

Update 3: See Bernard's solution below with the floatrow package. It may be the most concise.

  • I would use the width=\linewidth option instead of scale=0.5. – Mico Dec 10 '14 at 6:30
  • You're right: width=\linewidth definitely makes things look more balanced and stable, and you can "scale" things just as well by writing width=1.1\linewidth. I'll updated the question text to reflect this. – user174118 Dec 10 '14 at 7:45
3

I would use a single figure environment, start the adjustwidth environment inside the figure environment, and use two minipage environments, side by side, to display the two images; each can be given its own \caption. (The frame lines in the screenshot depict the ordinary page margins.)

enter image description here

\documentclass[letterpaper,11pt]{article} 
\usepackage[demo]{graphicx} % omit 'demo' option in real doc
\usepackage[space]{grffile} % for filenames with spaces
\usepackage{float} 
\usepackage{chngpage}
\usepackage{caption}
\usepackage{calc}
\usepackage[showframe]{geometry} % omit 'showframe' option in real doc
\begin{document}

\begin{figure}[ht!] 
\begin{adjustwidth}{-1.25cm}{-1.25cm}  % choose margin adjustments
\begin{minipage}{0.48\linewidth}
\caption{Schooling Time Shares}
\includegraphics[width=\linewidth]{Schooling Time Share over Time.png} 
\end{minipage}
\hspace*{\fill}  % spread out the two minipages
\begin{minipage}{0.48\linewidth}
\caption{Training Time Shares}
\includegraphics[width=\linewidth]{Training Time Share over Time.png}
\end{minipage} 
\end{adjustwidth}
\end{figure}

\end{document}

Addendum: You mention in a comment that you weren't sure whether you should use subfigures. That decision depends mostly on how the two images are related to each other. If they're not particularly related, it makes sense to assign separate, figure-level captions to them. If, on the other hand, they're related quite closely, it's probably a good idea to treat them as subfigures. Fortunately, it's not hard to do so: (i) load the subcaption package instead of (or in addition to) the caption package, (ii) replace minipage with subfigure (four instances), and (iii) provide a new \caption statement for the overall figure. The earlier captions, previously numbered 1 and 2, will now be labeled (a) and (b).

enter image description here

\documentclass[letterpaper,11pt]{article} 
\usepackage[demo]{graphicx} % omit 'demo' option in real doc
\usepackage[space]{grffile} % for filenames with spaces
\usepackage{float} 
\usepackage{chngpage}
\usepackage{subcaption}
\usepackage{calc}
\usepackage{geometry}
\begin{document}

\begin{figure}[ht!]
\caption{Two Types of Time Shares} 
\begin{adjustwidth}{-1.25cm}{-1.25cm}  % choose margin adjustments
\begin{subfigure}{0.48\linewidth}
\caption{Schooling Time Shares}
\includegraphics[width=\linewidth]{Schooling Time Share over Time.png} 
\end{subfigure}
\hspace*{\fill}  % spread out the two minipages
\begin{subfigure}{0.48\linewidth}
\caption{Training Time Shares}
\includegraphics[width=\linewidth]{Training Time Share over Time.png}
\end{subfigure} 
\end{adjustwidth}
\end{figure}

\end{document}
  • Thank you for this kind and thorough explanation. I updated my question above to reflect your suggestion. Quick question though: Is there a way I can manually shift the caption say a couple cm to the right? I tried putting in things like hspace* or mbox, but they introduced a new line instead. – user174118 Dec 10 '14 at 6:12
  • @user174118 - I suppose you could insert something like \kern2cm at the start or end of the argument of \caption, depending on whether the caption string should be shifted to the right or left. – Mico Dec 10 '14 at 6:24
  • \kern0.2cm did the trick! But it looks like in principle \kern just shifts the text over; with 0.2cm it is able to makes things look pretty, but is there a way to shift the reference label "Figure X:" over as well? Unnecessary for this application but if there is such a way it would be nice to know – user174118 Dec 10 '14 at 8:09
1

A very simple solution with the floatrow package. It is an extension of the float package, and you shouldn't load it when loading floatrow. The \FBwidth optyion sets the caption width to the width of the figure.

\documentclass[letterpaper,11pt]{article}
\usepackage{graphicx} % omit 'demo' option in real doc
\usepackage[space]{grffile} % for filenames with spaces
\usepackage{chngpage}
\usepackage{caption}
\usepackage{calc}
\usepackage[showframe]{geometry} % omit 'showframe' option in real doc

\usepackage{floatrow}
\begin{document}

\begin{figure}[ht!]
\begin{floatrow}
\ffigbox[\FBwidth]{\caption{Perseus Rescuing Andromeda}}
{\includegraphics[width=\linewidth]{Piero_di_Cosimo_2.jpg}}
\ffigbox[\FBwidth]{\caption{The Death of Procris}}
{\includegraphics[width=\linewidth]{Piero_di_Cosimo_1.jpg}}
\end{floatrow}
\end{figure}

\end{document} 

enter image description here

If you want thefigures to overflow both margin, you can use \llap and\rlap as follows:

\documentclass[letterpaper,11pt]{article}
\usepackage{graphicx, mathtools} % omit 'demo' option in real doc
\usepackage[space]{grffile} % for filenames with spaces
\usepackage{changepage}
\usepackage{caption}
\usepackage{calc}
\usepackage[showframe]{geometry} % omit 'showframe' option in real doc

\usepackage{floatrow}
\begin{document}

\begin{figure}[ht!]
\begin{floatrow}
\llap{\ffigbox[1.2\linewidth]{\caption{Perseus Rescuing Andromeda}}
{\includegraphics[width =\linewidth]{Piero_di_Cosimo_2.jpg}}}
\rlap{\ffigbox[1.2\linewidth]{\caption{The Death of Procris}}
{\includegraphics[width = 1\linewidth]{Piero_di_Cosimo_1.jpg}}}
\end{floatrow}
\end{figure}

\end{document} 

enter image description here

  • Thanks, but is there an easy way to make the pictures slightly larger and spillover into the margins, while keeping the horizontal alignment of the captions look nice? One method I tried for your code is using \hspace*{-1.3cm}\resizebox{0.7\paperwidth}{!} before floatrow which successfully enlarged the pictures and kept the alignment, but also blew up the caption font sizes. So I then introduced \captionsetup{font=scriptsize}. But I have a feeling there's gotta be an easier way. – user174118 Dec 10 '14 at 20:44
  • @user174118: I have a simple solution. See my updated answer. – Bernard Dec 10 '14 at 22:11
  • Your solution is perfect--it's elegant and automatic, rather than requiring any additional adjustments. I wasn't sure how kosher it is to accept someone else's answer after accepting one already, but I would if it were. Thank you. – user174118 Dec 10 '14 at 22:43
  • @user174118: That's not important. What I care for is trying to be helpful. – Bernard Dec 10 '14 at 23:09

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.