Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical alignment of subfigures LATEX

I am working on my thesis and I am struggling with placing 2 images next to each other, so that the second image would be centered vertically along the first one. I was also trying to use subfigure instead of subfloat but neither of them works.

This is how it looks alt text http://img51.imageshack.us/img51/1174/screenshot20100224at712.png

and my code is:

\begin{figure}[H]
\centering  \subfloat[H][sparse($\mathbf{A}$)]{\includegraphics[width=0.28\textwidth]{sparsesmall} \label{sparse}}
    \subfloat[H][full($\mathbf{A}$)]{\includegraphics[width=0.55\textwidth]{fullsmall}\label{full}}
  \caption{Representation of $\mathbf{A}$ in MATLAB}
  \label{schematic}
\end{figure}

Any suggestions to make it look better than now? Thx

like image 995
Veronika D Avatar asked Feb 24 '10 18:02

Veronika D


People also ask

How do I add vertical space between Subfigures in latex?

You could insert the instructions \par\bigskip between the second and third subfigure to create a bit of extra vertical space between the two sets of subfigures. If \bigskip is too much for your taste, try using \medskip .

How do you do Subfigures in latex?

To create subfigure in latex, you can use both \begin{minipage}... \end{minipage} and \begin{subfigure}... \end{subfigure} block to insert subfigures or sub-images. Subfigurs are generally inserted horizontally in one or multiple rows.


4 Answers

You can also use \raisebox{x}{\includegraphics[...]{...}} where x is negative to shift it downwards and positive to shift upwards.

like image 158
krashalot Avatar answered Oct 12 '22 12:10

krashalot


Edit: it seems like subfig package has problems, particularly when working with hyperref. In that case, try subcaption package as mentioned in this answer.

If you use subfig package, you can do this easily. The solution is in section 5.4 of the manual:

\newsavebox{\tempbox}
\begin{figure}[H]
\sbox{\tempbox}{\includegraphics[width=0.28\textwidth]{sparsesmall}}
\subfloat[sparse($\mathbf{A}$)]{\usebox{\tempbox}\label{sparse}}%
\qquad
\subfloat[full($\mathbf{A}$)]{\vbox to \ht\tempbox{%
  \vfil
  \includegraphics[width=0.55\textwidth]{fullsmall}
  \vfil}\label{full}}%
  \caption{Representation of $\mathbf{A}$ in MATLAB}\label{schematic}
\end{figure}

I haven't tested it, and there may be typos, but it should work.

like image 20
Alok Singhal Avatar answered Oct 12 '22 11:10

Alok Singhal


Another solution (which works with the subcaption package is

\begin{figure}[p]
        \centering
        \begin{subfigure}{.49\linewidth}
            \centering
            \caption{Large Picture}
            \includegraphics{LARGEPIC}
        \end{subfigure}
        \hfill
        \begin{subfigure}{.49\linewidth}
            \centering
            \caption{SMALL PIC}
            \includegraphics{small picture}
            \begin{minipage}{.1cm}
            \vfill
            \end{minipage}
        \end{subfigure} 
        \caption{Two pictures}
\end{figure}

The \vfill alone does not work, that's why it is put into the minipage

like image 42
Jonas Avatar answered Oct 12 '22 11:10

Jonas


My method is using square minipage which centers its contents:

\begin{figure}
\subfloat[Figure a]{%
\begin{minipage}[c][1\width]{0.5\textwidth}%
\includegraphics[clip,width=1\textwidth]{figurea}%
\end{minipage}}\subfloat[Figure b]{\centering{}%
\begin{minipage}[c][1\width]{0.5\textwidth}%
\begin{center}
\includegraphics[clip,width=0.6\textwidth]{figureb}
\par\end{center}%
\end{minipage}}
\caption{main caption}
\end{figure}

This code was generated by LyX, however, so it's a bit ugly.

like image 43
valhallasw Avatar answered Oct 12 '22 11:10

valhallasw