# How to preserve the indentation when using standalone or preview?

The following output has no correct paragraph indentation after incorporating standalone documentclass or preview package.

\documentclass[border=12pt,preview]{standalone}
\parindent=12pt% does not work!

\begin{document}
The position of a particle moving along the $x$-axis is given as
$s_t=s_0+v_0t+\frac 1 2 at^2$
where $s_0$, $v_0$, $a$, and $t$ represent the initial position, initial speed, acceleration, and the time, respectively.
Even though you are not interested in physics, please be quiet.

And now \ldots
\end{document}


How to solve this issue?

-

The preview environment uses \@arrayparboxrestore that kills the parindent, just like it happens in minipage and in \parbox.

You can restore the normal parindent by patching \preview:

\documentclass[border=12pt,preview]{standalone}

\usepackage{etoolbox}
\edef\keptparindent{\the\parindent}
\patchcmd{\preview}
{\ignorespaces} %%% \preview ends with \ignorespaces
{\parindent\keptparindent\ignorespaces}
{}{}

\begin{document}
\begin{preview}
The position of a particle moving along the $x$-axis is given as
$s_t=s_0+v_0t+\frac 1 2 at^2$
where $s_0$, $v_0$, $a$, and $t$ represent the initial position,
initial speed, acceleration, and the time, respectively.
Even though you are not interested in physics, please be quiet.

And now \ldots
\end{preview}
\end{document}


-
It should be regarded as a bug that have to be fixed for the next build. :-) –  kiss my armpit Feb 14 '13 at 14:12
@GarbageCollector I don't think so. However preview and standalone should at least document it. –  egreg Feb 14 '13 at 14:17
Why did the author design minipage and parbox without preserving \parindent? –  kiss my armpit Feb 14 '13 at 14:23
@GarbageCollector Ask Leslie Lamport. ;-) The idea is, I believe, to start in a well determined status. –  egreg Feb 14 '13 at 14:25
Then it should be a bug. :-) –  kiss my armpit Feb 14 '13 at 14:27