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.

I have one figure which contains 2 figures:

\begin{figure*}
  \begin{center}
    \subfigure[A]{
      \begin{tikzpicture}
      ....
      \end{tikzpicture}
    }
    \quad
    \subfigure[B]{
      \begin{tikzpicture}
      ....
      \end{tikzpicture}
    }
  \end{center}
\end{figure*}

Could anyone tell me how to add a vertical line between them to visually separate them?

share|improve this question
1  
A tabular with {c|c} maybe? –  percusse Mar 5 '13 at 22:16
    
Can I still keep subfigure inside tabular? –  SoftTimur Mar 5 '13 at 22:38
1  
@SoftTimur Yes, you can. Note that the subfigure package is obsolete and either subfig or subcaption should be used; the former has a syntax like subfigure (but you should use \subfloat instead of \subfigure). There are many spurious spaces in your code. –  egreg Mar 5 '13 at 22:48
1  
Regarding the spurious spaces, do you mean I should add % after {? –  SoftTimur Mar 5 '13 at 22:51

1 Answer 1

up vote 4 down vote accepted

Following the advice of percusse and egreg:

\documentclass{article}

\usepackage{tikz}
\usepackage{subcaption}

\begin{document}
\begin{figure}
    \centering
    \begin{tabular}{c|c}
        \begin{subfigure}[b]{0.45\textwidth}
            \centering
            \begin{tikzpicture}
                \fill[red] (0,0) rectangle (3,3);   
            \end{tikzpicture}
            \caption{A red square}
            \label{fig:red_square}
        \end{subfigure}
        &
        \begin{subfigure}[b]{0.45\textwidth}
            \centering
            \begin{tikzpicture}
                \fill[blue] (0,0) rectangle (3,3);      
            \end{tikzpicture}
            \caption{A blue square}
            \label{fig:blue_square}
        \end{subfigure}
    \end{tabular}
    \caption{Two squares}
    \label{fig:two_squares}
\end{figure}            
\end{document}

enter image description here

share|improve this answer
    
Thank you... But if you put \begin{subfigure}[A longer Text]{0.45\textwidth}, it seems that the labels under the figures are not well placed... –  SoftTimur Mar 5 '13 at 23:18
    
The optional argument of the subfigure environment does not correspond to its caption, but to a placement specifier; see the table summarising those options on en.wikibooks.org/wiki/LaTeX/…. If you want to add a caption to each subfigure, and possibly to the figure that contains them, simply use \caption as in my code, which I just updated. –  Jubobs Mar 5 '13 at 23:37

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.