如何在使用独立或预览时保留缩进?

如何在使用独立或预览时保留缩进?

standalone合并文档类或preview包后,以下输出没有正确的段落缩进。

在此处输入图片描述

\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}

如何解决这个问题?

答案1

环境preview使用\@arrayparboxrestore杀死父母,就像在minipage和中发生的那样\parbox

您可以通过修补来恢复正常的 parindent \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}

在此处输入图片描述

相关内容