# Difference with standalone and preview? [duplicate]

This question already has an answer here:

I have a table, but for cleanliness (I'll use the figure in a paper and in talks), I'd like to compile to a single PDF and include it with includegraphics instead of having the table rendered within the paper.

In the paper, it renders fine. I use these options:

\documentclass[11pt,twocolumn]{article}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}


But when I move the table into a standalone document with preview, the graphics are far too big for the page. Of course, I can still simply render the figure in its own table inside paper.tex, but I'd like to figure out why this happens. Can you figure it out?

Here is the preview document:

\documentclass[preview=true]{standalone}

\usepackage{standalone}
\usepackage{rotating}
\usepackage{array}

\usepackage{graphicx}
\usepackage{multirow}

\pagestyle{empty}

\begin{document}

\begin{tabular}{m{0.1in}m{1.4in}m{1.4in}m{1.4in}m{1.4in}m{1.4in}}
&
\multirow{3}{*}{\begin{minipage}{1.4in}\centering {\bf (a)} Control-control densities \end{minipage}} &
% 1.4 * 3
\multicolumn{3}{c}{ \begin{minipage}{4.2in}\centering {\bf (b)} Case-control vs. control-control log densities \end{minipage} } \\
& & \multicolumn{3}{c}{ \begin{minipage}{4.2in}\centering {\includegraphics[width=4.2in]{colorbar.pdf}} \end{minipage} }\\

& & \begin{minipage}{1.4in} \centering {0 differential} \end{minipage} & \begin{minipage}{1.4in} \centering {53 differential} \end{minipage} & \begin{minipage}{1.4in} \centering {302 differential} \end{minipage}\\

\begin{sideways}Replicate 1\end{sideways} &
\includegraphics[width=1.4in]{null_1-crop.pdf} &
\includegraphics[width=1.4in]{rep_1_0-crop.pdf} &
\includegraphics[width=1.4in]{rep_1_53-crop.pdf} &
\includegraphics[width=1.4in]{rep_1_302-crop.pdf} \\

\begin{sideways}Replicate 2\end{sideways} &
\includegraphics[width=1.4in]{null_2-crop.pdf} &
\includegraphics[width=1.4in]{rep_2_0-crop.pdf} &
\includegraphics[width=1.4in]{rep_2_53-crop.pdf} &
\includegraphics[width=1.4in]{rep_2_302-crop.pdf} \\
\end{tabular}

\end{document}

-
why don't you use \documentclass[border=15pt]{standalone}? without the setting of preview=true! –  Herbert May 17 at 20:02
To be honest, I'm not sure-- can you enlighten me below? I would be happy to +1 and accept a superior solution. –  Oliver May 17 at 20:12
try it out ... with your example and without loading the package geometry. –  Herbert May 17 at 20:17
I agree with Herbert. Just remove the preview=true option and control the border margins with the border option as Herbert has suggested. –  hpesoj626 May 18 at 1:44
Also, \usepackage{standalone} is superfluous in your MWE. –  hpesoj626 May 18 at 1:46
show 1 more comment

## marked as duplicate by Martin Scharrer♦May 19 at 9:37

\usepackage[margin=1in]{geometry}


Adding it to the standalone document did the trick.

-
I'm the author of standalone. Using geometry with the standalone class should not be required and is in general not recommended, because then both will influence the page margin or size. –  Martin Scharrer May 19 at 7:45

When I remove the trailing empty line after the table or remove the preview option (standalone v1.x) then the issues disappear. Please see Standalone package creates a page with a fixed width which explains why this happens with the preview option. Because of this I consider your question a duplicate of that question and will close it as such shortly. However, I wanted to post the corrected code for you before that. Please find it below.

Note that you also don't need to load the standalone package as long you don't want to include other standalone documents. Please also don't use the old LaTeX 2.0 font macros like \bf any longer. See "Correct" way to bold/italicize text? for an explanation.

\documentclass[preview]{standalone}

\usepackage{rotating}
\usepackage{array}

\usepackage{graphicx}
\usepackage{multirow}

\begin{document}
\begin{tabular}{m{0.1in}m{1.4in}m{1.4in}m{1.4in}m{1.4in}m{1.4in}}
&
\multirow{3}{*}{\begin{minipage}{1.4in}\centering {\bfseries (a)} Control-control densities \end{minipage}} &
% 1.4 * 3
\multicolumn{3}{c}{ \begin{minipage}{4.2in}\centering {\bfseries (b)} Case-control vs. control-control log densities \end{minipage} } \\
& & \multicolumn{3}{c}{ \begin{minipage}{4.2in}\centering {\includegraphics[width=4.2in]{example-image.pdf}} \end{minipage} }\\

& & \begin{minipage}{1.4in} \centering {0 differential} \end{minipage} & \begin{minipage}{1.4in} \centering {53 differential} \end{minipage} & \begin{minipage}{1.4in} \centering {302 differential} \end{minipage}\\

\begin{sideways}Replicate 1\end{sideways} &
\includegraphics[width=1.4in]{example-image.pdf} &
\includegraphics[width=1.4in]{example-image.pdf} &
\includegraphics[width=1.4in]{example-image.pdf} &
\includegraphics[width=1.4in]{example-image.pdf} \\

\begin{sideways}Replicate 2\end{sideways} &
\includegraphics[width=1.4in]{example-image.pdf} &
\includegraphics[width=1.4in]{example-image.pdf} &
\includegraphics[width=1.4in]{example-image.pdf} &
\includegraphics[width=1.4in]{example-image.pdf} \\
\end{tabular}
\end{document}

-
Have you read my bug report e-mail? Here is the code to regenerate the issue. –  Stiff Jokes May 21 at 6:54
@ClickMe: Please use the chat or email for such messages and not unrelated posts. I have read it but didn't had time to test it. What makes you think this is a bug in standalone? Probably the gather* environment adds the space somehow. –  Martin Scharrer May 21 at 7:33