3

So I have a document which in a lot of places uses one pstree (part of the pstricks package) and a simple tabular side by side...I do this with subfigures. The problem is that because the pstree image is bigger than the table there is much empty space under the table. I want the table to be vertically centered according to the height of the pstree. Is there a way to do this?

\begin{figure}[h]
\begin{center}

\subfigure {
    PSTree code
}

\hspace{40pt}

\subfigure {
    \begin{tabular}{c|c|c|}    
        The Table
    \end{tabular}
}

\end{center}

\caption{The caption for both}
\label{mylabel:1}
\end{figure}
1

The following code shows two options; the first one uses minipages and the second one uses the subfigure and subtable environments from the subcaption package; the alignment is achieved by using the optional argument of the environments (I used a black rectangle to simulate the tree):

\documentclass[11pt]{article}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}

\begin{figure}[!ht]
  \begin{minipage}[c]{.4\textwidth}
    \centering
    \rule{3cm}{7cm}% to simulate the tree
  \end{minipage}\hfill
  \begin{minipage}{.5\textwidth}
    \centering
    \begin{tabular}[C]{c|c|c|}    
      column1a & column2a & column3a \\
      column1b & column2b & column3b
    \end{tabular}
  \end{minipage}
  \caption{The caption for both}
  \label{mylabel:1}
\end{figure}

% requires the subcaption and the caption packages
\begin{figure}[!ht]
  \begin{subfigure}[c]{.4\textwidth}
    \centering
    \rule{3cm}{7cm}% to simulate the tree
  \end{subfigure}\hfill
  \begin{subtable}{.5\textwidth}
    \centering
    \begin{tabular}[C]{c|c|c|}    
      column1a & column2a & column3a \\
      column1b & column2b & column3b
    \end{tabular}
  \end{subtable}
  \caption{The caption for both}
  \label{mylabel:2}
\end{figure}

\end{document}

EDIT: the subfigure package is obsolete and shouldn't be used anymore. A good replacement is the subcaption package (although in this particular case there seems to be no need to use it since no separate caption is required for the tree and the table; standard minipages can do the job).

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.