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 would like my 'figure' environments to be exported tightly cropped. If I use this:

\usepackage[floats,active,tightpage]{preview}

the caption is included. If I use this (of course, with real \includegraphics commands instead of these filler boxes):

\usepackage[graphics,active,tightpage]{preview}

each subfigure is exported separately so I lose the arrangement/connection of the subfigures.

1) Is there a way to get this float composed of subfig's to be tightly cropped excluding the caption?

2) Is there a way to get it to crop the figures horizontally as well? The vertical cropping seems to work (if I omit the caption command), but the output is always the pagewidth.

\documentclass[10pt]{article}

\usepackage[floats,active,tightpage]{preview}

\usepackage{graphicx}

\usepackage[caption=false,format=hang]{subfig}

\begin{document}

\def\FigSize{.23}
\begin{figure}[htbp!]
\subfloat[]
  {
  \fbox{\rule{0pt}{2in} \rule{\FigSize \linewidth}{0pt}}
  }
\subfloat[]
  {
  \fbox{\rule{0pt}{2in} \rule{\FigSize \linewidth}{0pt}}
  }
\caption{Test Caption}
\end{figure}

\end{document}

I tried putting the subfigures in a minipage, but it seems to put A directly ontop of B? And it still has not cropped the result horizontally?

\documentclass[preview]{standalone}
\usepackage{mwe}
\usepackage{subcaption}

\begin{document}

\def\FigSize{.33}
\begin{figure}
\begin{minipage}{2\FigSize \linewidth}
  \begin{subfigure}[b]{\FigSize \textwidth}
  \centering
    \includegraphics[width=\FigSize \textwidth]{example-image-a}
  \phantomcaption
  \end{subfigure}
  \begin{subfigure}[b]{\FigSize \textwidth}
  \centering
    \includegraphics[width=\FigSize \textwidth]{example-image-b}
  \phantomcaption
  \end{subfigure}
\end{minipage}
\end{figure}

\end{document}
share|improve this question

1 Answer 1

You can use the standalone class and subcaption package for the same use.

\documentclass[preview]{standalone}
\usepackage{mwe} %<- For dummy images replace with graphicx later
\usepackage{subcaption}

\begin{document}
\begin{figure}
\begin{subfigure}[b]{.333\textwidth}
\centering
  \includegraphics[width=3cm]{example-image-a}
\phantomcaption
\end{subfigure}%
\begin{subfigure}[b]{.333\textwidth}
\centering
  \includegraphics[width=3cm]{example-image-b}
\phantomcaption
\end{subfigure}%
\begin{subfigure}[b]{.333\textwidth}
\centering
  \includegraphics[width=3cm]{example-image-c}
\phantomcaption
\end{subfigure}%

\end{figure}
\end{document}

enter image description here

share|improve this answer
    
what is the difference between \phantomcaption and just not having a \caption call at all? I was trying to leave my \caption calls there, but "disable" them for the purposes of running these "previews". Also, if you modify your example to have only 2 subfigures, the page is cropped to the right height, but the width still seems to be a full page. I.e. the output is the same size as the ABC figure, but C is missing but not cropped off. –  David Doria Oct 31 '12 at 11:23
    
@DavidDoria Note that it's an example and I have provided 3cm explicitly. You can omit the caption too. The page size is different because these are inside the figure environment. If you don't want the text width then you can put them into other boxes, mini pages such that the cropping is done with respect to the boxes avoiding an XY problem. –  percusse Oct 31 '12 at 11:32
    
I tried putting the subfigures in a minipage: pastebin.com/3tvPLKsR (I don't know how to post follow up code here without creating an Answer, which I don't think is the right thing to do?), but it seems to put A directly ontop of B? And it still has not cropped the result horizontally? –  David Doria Oct 31 '12 at 14:45
    
@DavidDoria You can always edit your question and add details. I'll try to see this as soon as I have some extra time. –  percusse Oct 31 '12 at 17:08
    
I got closer over here: tex.stackexchange.com/questions/79877/… (I started a new thread since this one got way off topic of excluding the captions :) ). The question now is just how to make the subfloat letters (like (a), etc) stay aligned with the subfloats. –  David Doria Oct 31 '12 at 18:15

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.