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.
\documentclass[demo]{article}
\usepackage{tabu}
\usepackage{tikz}
\usepackage{capt-of}
\usepackage{subfig}
\captionsetup[subfigure]{labelformat = parens}
%\usepackage[demo]{graphicx}                                                        
\begin{document}
\begin{minipage}{\linewidth}
  \centering
  \begin{tabular}{c@{\hspace{.5em}}c}
    \includegraphics[width = 2.5in]{something}
    \captionof{figure}[short]{figure 1}
    \label{one} &
    \begin{tikzpicture}
      \draw (0,0) -- (2,0);
    \end{tikzpicture}
    \captionof{figure}[short]{figure 2}
    \label{two}
  \end{tabular}
  \caption[short]{figures}
  \label{three}
\end{minipage}
\end{document}

I want to put a eps file and a TikZ picture side by side as subfigures in a a minipage, but no matter what I try this doesn't work. I also tried including the TikZ picture with \includestandalone but that failed as well. How can I do this?


Gonzalo Medina

One question, how can I avoid the captions running to close and looking sloppy?

enter image description here

share|improve this question
    
You need to convert something.eps to something.pdf first (using epstopdf). The EPS (Postscript) and PDF formats can't be mixed together... –  Werner Jul 31 '13 at 3:41

1 Answer 1

up vote 1 down vote accepted

You can nest minipages:

\documentclass[demo]{article}
\usepackage{tabu}
\usepackage{tikz}
\usepackage{capt-of}
\usepackage{subfig}
\captionsetup[subfigure]{labelformat = parens}

\begin{document}

\noindent\begin{minipage}{\linewidth}
  \hfill\begin{minipage}[b]{.45\linewidth}
  \centering
    \includegraphics[width = 2in]{something}
    \captionof{subfigure}[short]{A subfigure with a long caption spanning several lines}
    \label{one}
    \end{minipage}\hfill%
  \begin{minipage}[b]{.45\linewidth}
  \centering
    \begin{tikzpicture}
      \draw (0,0) -- (2,0);
    \end{tikzpicture}
    \captionof{subfigure}[short]{Another subfigure with a long caption spanning several lines}
    \label{two}
    \end{minipage}
  \captionof{figure}{A \LaTeX\ figure with two subfigures}
  \label{three}
\end{minipage}\hfill\null

\end{document}

enter image description here

share|improve this answer
    
Your answer worked great. However, I have two questions. What can I do if the captions of the subfigures are too long (see edit to post for a visual)? To add LaTeX in the \captionof, I need \pdftostring (something syntactic like that)? –  dustin Jul 31 '13 at 13:25
    
@dustin 1) You can reduce the width of the inner minipages and use \hfill to center the subfigures (see my updated answer). 2) No; normally you don't need anything special to use \LaTeX inside a caption; in my updated answer I used \LaTeX inside \captionof without problems. –  Gonzalo Medina Jul 31 '13 at 13:44

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.