Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

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).

share|improve this answer
    
Works great with minipages...thank you! –  Icoo May 8 '11 at 19:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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