[Tex/LaTex] fullwidth: Trying to change paragraph margins doesn’t work as expected

fullwidthindentation

The fullwidth package (current version 0.1) by Marco Daniel "provides the environment fullwidth which allows to set the left and right margins in a very simple way" (manual, p. 1). According to the manual, the package is based on the algorithm of the mdframed package (current version 1.0) by the same author.

However, trying to change margins of individual paragraphs with fulllwidth doesn't yield the desired results. Setting the leftmargin option to a positive value will move the whole paragraph to the right (into the right page margin), and setting rightmargin to a positive value doesn't have any effect at all. (The mdframed package, on the other hand, changes the respective margins as expected [and adds a frame around the paragraph].) fullwidths behaviour can't be correct, can it?

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

enter image description here

Best Answer

@lockstep: Do you think that the following behavior is more efficient?

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