I have a float containing subfigures. I want to "export" it as a single item so that I can include it elsewhere as one object. I tried to use the Preview package with [active,floats,tightpage], but it only makes the page tight vertically - it leaves significant white space to the right of the second subfigure in the example below:
\documentclass{article}
\usepackage{mwe}
\usepackage{subcaption}
\usepackage[active,floats,tightpage]{preview} % include this last
\begin{document}
\def\FigSize{.33}
\begin{figure}
\begin{subfigure}[b]{\FigSize \textwidth}
\includegraphics[width=\FigSize \textwidth]{example-image-a}
\end{subfigure}
\begin{subfigure}[b]{\FigSize \textwidth}
\includegraphics[width=\FigSize \textwidth]{example-image-b}
\end{subfigure}
\end{figure}
\end{document}
Is there a way to make it crop in the horizontal direction as well?
I have also tried this:
\documentclass[preview]{standalone}
\usepackage{mwe}
\usepackage[]{subfig}
\begin{document}
\def\FigSize{.23}
\begin{figure}[htbp!]
\centering
\subfloat[]
{
\includegraphics[width=3cm]{example-image-a}
}
\subfloat[]
{
\includegraphics[width=3cm]{example-image-b}
}
\end{figure}
\end{document}
but the result is similar in that the output is still the full page width rather than being tight to the two subfigures.
------------- Edit ----------------
As Peter Grill suggested, adding 'varwidth' does indeed fix the simple demo. In my real case, I am using subfloats from subfig:
\documentclass[preview,varwidth]{standalone}
\usepackage{mwe}
\usepackage[]{subfig}
\begin{document}
\def\FigSize{.23}
\begin{figure}[htbp!]
\centering
\subfloat[]
{
\includegraphics[width=3cm]{example-image-a}
}
\subfloat[]
{
\includegraphics[width=3cm]{example-image-b}
}
\end{figure}
\end{document}
The cropping is still correct, but the (a) and (b) below the figures are not centered on the figures as they should be?
\documentclass[preview, varwidth]{standalone}
will fix the version using thestandalone
package.standalone
has special handling forfigure
. If you don't get a satisfactory answer here, I would recommend you crop only the actual figures viastandalone
. If the need is to ensure identical formatting of a group of figures, then you could just have a separate.tex
file, and import that in your main document. Sorry that I am unable to help you more with this.