0

I am using IEEETrans and the recommended subfig package. I have tikz graphics in subfigures, and I really want them to be aligned by their top bounding box (so that the nodes align).

The problem is, when I do that, the captions are not aligned anymore (see MWE). How can I have my cake and eat it too.

MWE:

\documentclass\[journal,compsoc,onecolumn,draftclsnofoot\]{IEEEtran}

\ifCLASSOPTIONcompsoc
\usepackage\[caption=false,font=normalsize,labelfon
t=sf,textfont=sf\]{subfig}
\else
\usepackage\[caption=false,font=footnotesize\]{subfig}
\fi

\usepackage{tikz}
\usetikzlibrary{positioning,shapes,arrows,calc,patterns,matrix,backgrounds,chains}

\begin{document}
    \begin{figure*}
        \subfloat\[A\]{
\begin{tikzpicture}\[baseline=(current bounding box.north)\]
\matrix (m)\[matrix of nodes\]
{
    a\\
};
\end{tikzpicture}           
}
        \subfloat\[B\]{
\begin{tikzpicture}\[baseline=(current bounding box.north)\]
\matrix (m)\[matrix of nodes\]
{
    a\\
    b\\
    c\\
    d\\
    e\\
};
\end{tikzpicture}
        }

    \end{figure*}
\end{document}]

Generated Output:

  • 1
    Maybe this answer can help you: tex.stackexchange.com/a/41172/134144. For top alinged images with bottom aligned captions, you just remove the .5 as follows: \raisebox{\dimexpr\ht\myimage-\height\relax}. Here is also another alternative using subcaption instead of subfig: tex.stackexchange.com/q/152818/134144 – leandriis Feb 1 '18 at 21:18
  • I tried the raisebox trick to no avail. Also, the IEEETrans documentation suggests to use subfig, so I'd like to stick to subfig. – malaverdiere Feb 1 '18 at 22:10
  • 1
    I got the raisebox trick to work by removing the baseline parameter from tikzpicture. Please make your comment into answer so you can get credit! – malaverdiere Feb 1 '18 at 22:21
1

The following is a modified version of a solution originally posted by Werner here: vertically align different size images in a figure* environment

\documentclass[journal,compsoc,onecolumn,draftclsnofoot]{IEEEtran}

\ifCLASSOPTIONcompsoc
\usepackage[caption=false,font=normalsize,labelfont=sf,textfont=sf]{subfig}
\else
\usepackage[caption=false,font=footnotesize]{subfig}
\fi

\usepackage{tikz}
\usetikzlibrary{positioning,shapes,arrows,calc,patterns,matrix,backgrounds,chains}

\begin{document}

\newsavebox{\myimage}   
\begin{figure*}
 \centering
 \savebox{\myimage}{%
    \begin{tikzpicture}
    \matrix (m)[matrix of nodes]
    {
    a\\
    b\\
    c\\
    d\\
    e\\
    };
    \end{tikzpicture}
 } % Store largest image
  \subfloat[A]{\raisebox{\dimexpr\ht\myimage-\height\relax}{%
    \begin{tikzpicture}
    \matrix (m)[matrix of nodes]
    {
    a\\
    };
    \end{tikzpicture}
    }} \quad
  \subfloat[B]{\usebox{\myimage}}
  \caption{This is a figure.}
\end{figure*}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.