GeneralStacked Graphics caption width override?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Klopstick
Posts: 16
Joined: Sat Jan 27, 2007 11:18 pm

Stacked Graphics caption width override?

Post by Klopstick »

I'm trying to put multiple images onto one page and have a caption for each. My approach is using stacked minipages with the \includegraphics in each one as follows:

Code: Select all

\begin{figure}
\centering
\begin{minipage}[b]{0.45\textwidth}
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}%
\hspace{0.04\textwidth}%
\centering
\begin{minipage}[b]{0.45\textwidth}
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}\\[20pt]
\centering
\begin{minipage}[b]{0.45\textwidth}
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}%
\hspace{0.04\textwidth}%
\centering
\begin{minipage}[b]{0.45\textwidth}
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}%
The problem I run into is that with long captions it still uses my initial declaration of width=.75\textwidth that I put in \captionsetup at the top of the doc to use with full page images. This messes up my stacking and the caption text overlaps, etc. How can I override my setting for a particular caption?

I have also tried to do the multi-image using subfigures instead of stacking, but I can't get the a. b. c. labels to turn off. Is it defined somehow in \thesubfigure ? I already have \captionsetup{labelformat=empty, ...} ,but that seems not to apply to subfigures.

What's my best approach?

Bruce
Last edited by Klopstick on Sat Feb 10, 2007 7:21 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Kris
Posts: 56
Joined: Sun Jan 14, 2007 4:04 pm

Stacked Graphics caption width override?

Post by Kris »

Hi Bruce!

Your initial declaration of the caption-width with width=.75\textwidth
is connected to your actual 'page-text-width'...

A minipage defines a \textwidth for it's own - so You just have to repeat \captionsetup{width=.75\textwidth}
'inside' the minipage for adjusting the width!

Code: Select all

\begin{figure}
\centering
\begin{minipage}[b]{0.45\textwidth}
%
\captionsetup{width=\textwidth}                             % actual width will be the minipage-textwidth of .45\textwidth
%
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}%
\hspace{0.04\textwidth}%
\centering
\begin{minipage}[b]{0.45\textwidth}
%
\captionsetup{width=\textwidth}                             % actual width will be the minipage-textwidth of .45\textwidth
%
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}\\[20pt]
\centering
\begin{minipage}[b]{0.45\textwidth}
%
\captionsetup{width=\textwidth}                             % actual width will be the minipage-textwidth of .45\textwidth
%
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}%
\hspace{0.04\textwidth}%
\centering
\begin{minipage}[b]{0.45\textwidth}
%
\captionsetup{width=\textwidth}                             % actual width will be the minipage-textwidth of .45\textwidth
%
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}}%
Regards
Kris
Last edited by Kris on Sat Feb 10, 2007 7:36 pm, edited 1 time in total.
Klopstick
Posts: 16
Joined: Sat Jan 27, 2007 11:18 pm

Stacked Graphics caption width override?

Post by Klopstick »

That makes perfect sense. I tried so many things, but the very obvious relationship of page/minipage just never occured to me. Thanks again, Kris!

Bruce
Last edited by Klopstick on Sat Feb 10, 2007 8:03 pm, edited 1 time in total.
Klopstick
Posts: 16
Joined: Sat Jan 27, 2007 11:18 pm

Re: Stacked Graphics caption width override?

Post by Klopstick »

Oh dear. NOW the pictures don't arrange themselves properly! They seem to want to stack vertically, but not even line up exactly above one another. I've tried making the minipage small enough to fit 2 wide on the page (I want a 2 pics wide by 2 pics high configuration if I can get it), but that doesn't change anything, they still string themselves raggedly down the page.

Picture 1 Picture 2
caption1 caption2

Picture3 Picture4
caption3 caption4

I'm getting errors as well (it pdf's OK without this section of code). Do I need some other include package? I think I'm beginning to lose my mind. :roll:

Bruce
User avatar
Kris
Posts: 56
Joined: Sun Jan 14, 2007 4:04 pm

Stacked Graphics caption width override?

Post by Kris »

Hi Bruce again...

...just move \centering from the outside
to the inside of Your minipage-environments:

Code: Select all

\begin{figure}
\centering                                                        % centers the whole figure-environment (here the 4 minipage array)
\begin{minipage}[b]{0.45\textwidth}
\centering                                                        % centers the graphic in the 1. minipage...
\captionsetup{width=\textwidth}                                   % actual width will be the minipage-textwidth of .45\textwidth
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}%
\hspace{0.04\textwidth}%
\begin{minipage}[b]{0.45\textwidth}
\centering                                                         % centers the graphic in the 2. minipage...
\captionsetup{width=\textwidth}                                   % actual width will be the minipage-textwidth of .45\textwidth
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}
\vspace{20pt}
\begin{minipage}[b]{0.45\textwidth}
\centering                                                         % centers the graphic in the 3. minipage...
\captionsetup{width=\textwidth}                                   % actual width will be the minipage-textwidth of .45\textwidth
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}%
\hspace{0.04\textwidth}%
\begin{minipage}[b]{0.45\textwidth}
\centering                                                         % centers the graphic in the 4. minipage...
\captionsetup{width=\textwidth}                                   % actual width will be the minipage-textwidth of .45\textwidth
\includegraphics[width=0.90\textwidth]{Portrait.jpg}
\caption{\textit{This is the freaking caption stuff!}}
\end{minipage}
\end{figure}
;)

Kris
Last edited by Kris on Sat Feb 10, 2007 10:02 pm, edited 2 times in total.
Klopstick
Posts: 16
Joined: Sat Jan 27, 2007 11:18 pm

Re: Stacked Graphics caption width override?

Post by Klopstick »

Kris,

Well, that's a help, but it wasn't the actual problem. I don't quite know how it happened, but a had a double curley brace at the end of each \end{minipage}, like this \end{minipage}} . It caused some real problems. Even the order of the images would invert.I had copied the basic code from somplace, so I assumed it was right. Somehow, the extra brace got in there and ruined things. The log was of no help, and it was just a paranoia on my part that made me go start counting opens and closes.

Now I get to feel foolish. :oops: I'll doubtless have more problems, both real and imagined in the near future! Stay tuned!

Bruce
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Stacked Graphics caption width override?

Post by localghost »

Why not use the subfig package? It does the whole layout for you in one figure environment.

Code: Select all

\begin{figure}[!p]
  \centering
  \subfloat[sub-caption1\label{subfig:subfig1]{body1}
  \subfloat[sub-caption2\label{subfig:subfig2]{body2}
  \subfloat[sub-caption3\label{subfig:subfig3]{body3}
  \subfloat[sub-caption4\label{subfig:subfig4]{body4}
% \caption{caption of the whole figure}\label{fig:figure}
\end{figure}
For further information refer to the documentation of subfig.
Post Reply