全宽:尝试更改段落边距无法按预期工作

全宽:尝试更改段落边距无法按预期工作

全屏宽度软件包(当前版本 0.1)由马可·丹尼尔 fullwidth“提供允许以非常简单的方式设置左边距和右边距的环境”(手册,第 1 页)。根据手册,该包基于框架同一作者的包(当前版本为1.0)。

但是,尝试使用 更改各个段落的边距fulllwidth不会产生预期的结果。将leftmargin选项设置为正值会将整个段落移到右侧(移到右侧页边距),而设置rightmargin为正值则不会产生任何效果。(mdframed另一方面,该包会按预期更改相应的边距 [并在段落周围添加一个框架]。)fullwidth的行为不可能正确,对吗?

\documentclass{article}

\usepackage[linewidth=1.2pt]{mdframed}
\usepackage{fullwidth}

\newcommand*{\sometext}{Lorem ipsum dolor sit amet, consectetuer
    adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
    adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu
    libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
    vehicula augue eu neque.}

\begin{document}

\section{\texttt{mdframed} works as expected}

\sometext

\begin{mdframed}[leftmargin=3em]
\sometext
\end{mdframed}

\begin{mdframed}[rightmargin=3em]
\sometext
\end{mdframed}

\section{But \texttt{fullwidth} doesn't}

\sometext

\begin{fullwidth}[leftmargin=3em]
\sometext
\end{fullwidth}

\begin{fullwidth}[rightmargin=3em]
\sometext
\end{fullwidth}

\end{document}

在此处输入图片描述

答案1

@lockstep:您认为以下行为更有效率吗?

\documentclass{article}
\usepackage{showframe}
\usepackage[linewidth=1.2pt]{mdframed}
\usepackage{fullwidth}

\newcommand*{\sometext}{Lorem ipsum dolor sit amet, consectetuer
    adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
    adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu
    libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
    vehicula augue eu neque.}

\makeatletter
\def\fullwidth@i[#1]{% default-Umgebung
  \begingroup
  \fullwidthsetup{#1}%%
   \fwd@twoside@checklength%
   \ifbool{fwd@twosidemode}%
    {\advance\fwd@width@length by -\fwd@outermargin@length
     \advance\fwd@width@length by -\fwd@outermargin@length}%
    {\advance\fwd@width@length by -\fwd@leftmargin@length
     \advance\fwd@width@length by -\fwd@rightmargin@length}%
   \let\width\z@%
   \let\height\z@%
   \setlength{\topsep}{\fwd@skipabove@length}%
   \begingroup%
     \let\partopsep\z@%
   \expandafter\endgroup%   
   \begin{fwd@trivlist}\item\relax%
   \hsize=\fwd@width@length\relax%
   \fwd@footnoteinput%
   \begin{fwd@lrbox}{\@tempboxa}%
 }
\makeatother

\begin{document}

\section{\texttt{mdframed} works as expected}

\sometext

\begin{mdframed}[leftmargin=3em]
\sometext
\end{mdframed}

\begin{mdframed}[rightmargin=3em]
\sometext
\end{mdframed}

\section{But \texttt{fullwidth} doesn't}

\sometext

\begin{fullwidth}[leftmargin=3em]
\sometext
\end{fullwidth}

\begin{fullwidth}[rightmargin=3em]
\sometext
\end{fullwidth}

\null\hfill\smash{\rule[1.5cm]{3em}{2pt}}
\end{document}

相关内容