3

I'm having trouble to define vertical spacing within a minipage, as \vspace seems to behave in a special way within it. For instance, in the example below I'd like to set the vertical spacing between figure A and B to 1cm, but it's being added at the end instead of in between the figures. What is the proper way of defining this spacing? Thanks, Jorge.

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{subfig}
\begin{document}


\begin{figure*}[!t]
\fbox{\noindent\begin{minipage}[b][6cm]{0.45\linewidth}
    \includegraphics[height=2cm,width=1.0\linewidth]{example-image}
    \subfloat[]{\includegraphics[height=2cm,width=1.0\linewidth]{example-image}}
\end{minipage}}%
\hfill
\fbox{\noindent\begin{minipage}[b][6cm]{0.45\linewidth}
    \includegraphics[height=2cm,width=1.0\linewidth]{example-image-a}
    \vspace{1cm}
    \subfloat[]{\includegraphics[height=2cm,width=1.0\linewidth]{example-image-b}}
\end{minipage}}%
\end{figure*}
\end{document}

Results:

enter image description here

EDIT: Adding some blanks do alter the behavior, but I'm still unable to get it right; moreover; a spurious indentation appears!:

\begin{document}
\begin{figure*}[!t]
    \fbox{\noindent\begin{minipage}[b][6cm]{0.45\linewidth}
        \includegraphics[height=2cm,width=1.0\linewidth]{example-image}
        \subfloat[]{\includegraphics[height=2cm,width=1.0\linewidth]{example-image}}
    \end{minipage}}%
    \hfill
    \fbox{\begin{minipage}[b][6cm]{0.45\linewidth}
        \includegraphics[height=2cm,width=1.0\linewidth]{example-image-a}
        \\
        \\
        \vspace{1cm}
        \subfloat[]{\includegraphics[height=2cm,width=1.0\linewidth]{example-image-b}}
    \end{minipage}}%
\end{figure*}
\end{document}

Result:

enter image description here

dontpanic
  • 809
  • it's nothing to do with minpage it would be the same without, you need a blank line before the vspace. Also \noindent in the \fbox is doing nothing. – David Carlisle Feb 25 '18 at 17:01
  • @DavidCarlisle: thanks; adding some blanks does alter the behavior, but I'm still unable to get it right; moreover; a spurious indentation appears (I've noticed this before, why is that?) – dontpanic Feb 25 '18 at 17:09
  • @DavidCarlisle: (the \noindent in \fbox I also added because it too was adding unwanted indentation under some circumstances) – dontpanic Feb 25 '18 at 17:10
  • your edit is headed by a comment about blank lines but does not add any blank lines so with the \\ the vspace will still be added after the second image. the indentation is because you have added a word space from the end of line after \vspace – David Carlisle Feb 25 '18 at 17:18
  • the content of \fbox is set in horizontal mode so ther eare no paragraphs so no paragraph indentation so \noindent will do nothing. You probably had a space there note \fbox{ a } is not the same as \fbox{a} \fbox{\noindent a} may appear to do something but it is just the lack of space token, \noindent does nothing. – David Carlisle Feb 25 '18 at 17:22

1 Answers1

6

If you use \vspace mid-paragraph then the space is added, after the paragraph has been broken in to lines, after the line where the vspace appeared. That means

  a\vspace{1cm} b

will typeset a b and then add 1cm of space after that line. This behaviour is well defined but almost never what you want, it is almost always better to leave a blank line before the \vspace so that the previous paragraph ends and TeX is in vertical mode so the space can be added at that point.

a

\vspace{1cm}
b

typesets a above b with 1cm more space than usual.

Note this behaviour of \vspace is unrelated to it being in a minipage or that the items in the paragraph are subfigures.

David Carlisle
  • 757,742
  • :thanks! could you please tell me why did the \ in my didn't work? I thought it was the same as a blank line. Also, why does it add (unwanted) indentation? – dontpanic Feb 25 '18 at 17:15
  • 1
    \\ is not at all like a blank line and does not end the paragraph see https://tex.stackexchange.com/questions/82664/when-to-use-par-and-when-or-blank-lines/82666#82666 – David Carlisle Feb 25 '18 at 17:18
  • Thanks so much for the link, now everything is much clearer! – dontpanic Feb 25 '18 at 17:20
  • I'm still wondering though about that spurious indentation which I run into time and again in many contexts... what causes it? – dontpanic Feb 25 '18 at 17:24
  • 1
    @dontpanic you added it, it is the space token (from end of line} that you added after \vspace if you do not have a blank line above then the space is seen in horizontal mode, so makes a word-space – David Carlisle Feb 25 '18 at 17:25
  • Thanks a million! That's something I've been wondering for a long time! Who would have imagined that a single % can make such a difference! (\vspace{1cm} vs. \vspace{1cm}%)!!! – dontpanic Feb 25 '18 at 17:31
  • 1
    @dontpanic well of course it's only needed because the blank line was missing as spaces are ignored in vertical mode. in horizontal mode, it is the difference between dont panic and dontpanic – David Carlisle Feb 25 '18 at 19:12