[Tex/LaTex] Side by side subfigures in lyx

lyxsubfloats

I am using lyx and want to put two figures side by side. I could do it by inserting two minipages separated by a \hfill inside a float but it only allows me to use separate captions rather than subcaptions (I want it to be labeled as fig 1a, fig 1b). Also by inserting float inside a float, the 2nd figure appeared below the first one rather than in side. Any tips would be really helpful.

Best Answer

The better approach I found, was to use subfigures (especially when you want to refer to subfigures as 1a or 1b. From the LaTeX FAQ:

  • Insert→Float→Figure
  • Again, Insert→Float→Figure (this inserts a "subfigure float" into the float)
  • Put the cursor right next to the subfloat
  • Insert→Formatting→Horizontal Space→Horizontal Fill or Ctrl- -> right-click on space -> select "Horizontal Fill" (to insert a stretchable horizontal space)
  • Insert→Float→Figure (this inserts another "subfigure float")
  • In each subfloat:add the graphics and edit the caption
  • To insert a vertical space, Insert→Formatting→Vertical Space→DefSkip.

Or if you could just use this code (this is LyX syntax; not LaTeX) from what I created (you may have to right click on the images and adjust the width % of the images):

\begin_layout Standard
\begin_inset Float figure
wide false
sideways false
status open

\begin_layout Plain Layout
\begin_inset Float figure
wide false
sideways false
status open

\begin_layout Plain Layout
\begin_inset Graphics
    filename images/Fig2_1.png
    scale 30

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Name1
\begin_inset CommandInset label
LatexCommand label
name "fig:label1"

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset space \hfill{}
\end_inset


\begin_inset Float figure
wide false
sideways false
status open

\begin_layout Plain Layout
\begin_inset Graphics
    filename images/Fig2_2.png
    scale 30

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Name2
\begin_inset CommandInset label
LatexCommand label
name "fig:Name2"

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset VSpace defskip
\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Float figure
wide false
sideways false
status open

\begin_layout Plain Layout
\begin_inset Graphics
    filename images/Fig2_3.png
    scale 30

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Name3
\begin_inset CommandInset label
LatexCommand label
name "fig:Name3"

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset


\begin_inset space \hfill{}
\end_inset


\begin_inset Float figure
wide false
sideways false
status open

\begin_layout Plain Layout
\begin_inset Graphics
    filename images/Fig2_4.png
    scale 30

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Name3
\begin_inset CommandInset label
LatexCommand label
name "fig:Name3"

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset


\end_layout

\begin_layout Plain Layout
\begin_inset Caption Standard

\begin_layout Plain Layout
Caption for figure
\begin_inset CommandInset label
LatexCommand label
name "fig:FigureLabel"

\end_inset


\end_layout

\end_inset


\end_layout

\end_inset

 
\end_layout

For doing the same thing in pure LaTeX:

\begin{figure}[tb]
\begin{center}
\subfigure[Name1]{\includegraphics[width=1.625in]{images/Fig2_1.png}}
\subfigure[Name2]{\includegraphics[width=1.625in]{images/Fig2_2.png}}
\subfigure[Name3]{\includegraphics[width=1.625in]{images/Fig2_3.png}}
\subfigure[Name4]{\includegraphics[width=1.625in]{images/Fig2_4.png}}
\end{center}
\caption{Caption for figure}
\label{figureLabel}
\end{figure}