1

If I use the code below the two images are stacked horizontally, but when I remove the %\qquad` the subfigures are stacked vertically. I'm using Kile editor on Linux CentOs. Any ideas?

\documentclass{article}
\usepackage{graphicx}
\usepackage{subcaption}

\begin{document}
 \begin{figure}[!h]

  \begin{subfigure}[c]{.7\textwidth}
    \includegraphics[width=\textwidth]{Image1.jpg}
    \caption{Image 1}
  \end{subfigure}
 %\qquad
  \begin{subfigure}[c]{.2\textwidth}
    \includegraphics[width=\textwidth]{Image2.jpg}
    \caption{Image 2}
  \end{subfigure}

 \end{figure}
\end{document}
6
  • 1
    you have a blank line (paragraph break) between the figures so naturally they appear one above the other. Commented Feb 2, 2018 at 19:28
  • 2
    I would expect then to be stacked vertically with or without the quad, does your real example not have the blank line? we can not run your example as the second one is missing ] and the image files are not available (you can use example-image in examples) Commented Feb 2, 2018 at 19:30
  • I changed the code to fix the missing bracket and the blank lines. @Mico: You are right! By removing the %qquad I was inserting a blank line and as a result the images were stacked vertically. I am new to latex so I'm sorry for my ignorance. Should I change the title of the post to make it more relevant to what the issue actually was or even remove it? Thanks!
    – d myl
    Commented Feb 3, 2018 at 22:04
  • 2
    @dmyl - Absolutely no reason for saying that you're "sorry for my ingnorance"! The uses of blank and non-blank times can be rather confusing, especially when one's new. No need to modify your posting any further.
    – Mico
    Commented Feb 3, 2018 at 22:46
  • 1
    @cfr surprisingly not, there is this tex.stackexchange.com/questions/230425/subfigure-alignments/… but really the opposite (adding a paragraph break to force the image to the next line) Commented Feb 4, 2018 at 9:49

1 Answer 1

3

subfigures are placed just like large letters, so to understand the positioning, think of replacing \begin{subfigure}...\end{subfigure} by X.

Then the cases you might consider are

1.

XX

two X with no space between.

2.

X X

two X with a space between

3.

X
X

The same output as 2, as a newline is the same as a space,

4.

X%
X

The same output as 1, as the newline/space has been commented out.

5. (your original)

X
\quad
X

two X with a space and and additional 1em space.

6.

X%
\quad
X

two X with 1em space between

7. (your original with \quad removed)

X

X

Two X in separate paragraphs, so vertically stacked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .