我有以下定义(下面的 MWE)lrbox
。如果我使用正常设置,parskip=off
交互\mdf@restoreparams
将按预期进行。在里面lrbox
我可以使用parskip
和parindent
。但如果我使用该选项,parskip=half
我会在保存框的开头获得额外的跳过。我该如何避免这种情况。
图片
梅威瑟:
\documentclass[parskip=half]{scrreprt}
\usepackage{kantlipsum}
\catcode`\@11\relax
\def\mdf@lrbox#1{%
\edef\mdf@restoreparams{%
\parindent=\the\parindent \parskip=\the\parskip}%
\setbox#1\vbox\bgroup%
\color@begingroup%
% \mdf@horizontalmargin@equation%
\columnwidth=\hsize%
\textwidth=\hsize%
\let\if@nobreak\iffalse%
\let\if@noskipsec\iffalse%
\let\par\@@par%
\let\-\@dischyph%
\let\'\@acci\let\`\@accii\let\=\@acciii%
\parindent\z@ \parskip\z@skip%
\linewidth\hsize%
\@totalleftmargin\z@%
\leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip%
\parfillskip\@flushglue \lineskip\normallineskip%
\baselineskip\normalbaselineskip%
%% \sloppy%
\let\\\@normalcr%
\hrule \@height\z@ \@width\hsize\relax
\mdf@restoreparams\relax
\@afterindentfalse%
\@afterheading%
}
\def\endmdf@lrbox{\color@endgroup\egroup}
\newbox\MyTestBox
\begin{document}
\mdf@lrbox\MyTestBox
\kant[1]
\kant[1]
\endmdf@lrbox
\fbox{\box\MyTestBox}
\end{document}
我没有标记这个问题,KOMA
因为使用标准类的标题可以达到相同的结果
\documentclass[]{report}
\usepackage{parskip}
或memoir
\documentclass[]{memoir}
\setlength{\parindent}{0pt}
\nonzeroparskip
答案1
出色地....
如果你不这样做
\hrule \@height\z@ \@width\hsize\relax
那么,您就无法在顶部获得 parskip 了。
然后在你的最终代码中,如果框的宽度不符合你的预期(因为没有添加段落材料)
\vbox{
hrule \@height\z@ \@width\hsize\relax
\unvbox the box you had
}
\documentclass[parskip=half]{scrreprt}
\usepackage{kantlipsum}
\catcode`\@11\relax
\def\mdf@lrbox#1{%
\edef\mdf@restoreparams{%
\parindent=\the\parindent \parskip=\the\parskip}%
\def\tmp{#1}%
\setbox#1\vbox\bgroup%
\color@begingroup%
% \mdf@horizontalmargin@equation%
\columnwidth=\hsize%
\textwidth=\hsize%
\let\if@nobreak\iffalse%
\let\if@noskipsec\iffalse%
\let\par\@@par%
\let\-\@dischyph%
\let\'\@acci\let\`\@accii\let\=\@acciii%
\parindent\z@ \parskip\z@skip%
\linewidth\hsize%
\@totalleftmargin\z@%
\leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip%
\parfillskip\@flushglue \lineskip\normallineskip%
\baselineskip\normalbaselineskip%
%% \sloppy%
\let\\\@normalcr%
% \hrule \@height\z@ \@width\hsize\relax
\mdf@restoreparams\relax
\@afterindentfalse%
\@afterheading%
}
\def\endmdf@lrbox{\color@endgroup\egroup
\ifdim\wd\tmp<\hsize
\typeout{making box fill width}
\setbox\tmp\vbox{%
\hrule \@height\z@ \@width\hsize\relax
\unvbox\tmp}%
\fi
}
\newbox\MyTestBox
\begin{document}
\mdf@lrbox\MyTestBox
\kant[1]
\kant[1]
\endmdf@lrbox
\fbox{\box\MyTestBox}
\mdf@lrbox\MyTestBox
\begin{tabbing}aaa\end{tabbing}
\endmdf@lrbox
\fbox{\box\MyTestBox}
\end{document}
答案2
您可以\vskip-\parskip
在 定义的末尾添加\mdf@lrbox
,即\@afterheading
和 右括号之间。
这将取消\parskip
第一个段落即将开始时自动插入的粘连。