New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect behavior in addmargin/adjustwidth #12

Closed
polysyllabic opened this Issue Dec 24, 2018 · 8 comments

Comments

Projects
None yet
2 participants
@polysyllabic
Copy link

polysyllabic commented Dec 24, 2018

The current version appears to be expanding paragraphs in a way that produces incorrect behavior with both the KOMA-Script addmargin and the changepage adjustwidth environment. For both, only the first and last lipsum paragraphs have the adjusted length. Anything in the middle goes to the full text width. This problem does not occur with lipsum 1.3.

\documentclass{scrreprt}
\usepackage{changepage}
\usepackage{lipsum}

\begin{document}
  
  \begin{addmargin}[0pt]{.5\textwidth}
    \lipsum [1-3]
  \end{addmargin}

  \begin{adjustwidth}{0pt}{.5\textwidth}
    \lipsum [1-3]
  \end{adjustwidth}

\end{document}

@patta42

This comment has been minimized.

Copy link
Owner

patta42 commented Dec 24, 2018

I can confirm this weird behavior and I have no faint idea where it does come from.

lipsum does not use any boxes that specify a length, thus this might(!) be a bug related to latex3, but again, I have no idea. Alas, I do not even have a workaround (except for using \lipsum[1]\par\lipsum[2]\par....

I'll try to figure out what happens here when I have time.

Thanks for reporting!

@polysyllabic

This comment has been minimized.

Copy link

polysyllabic commented Dec 24, 2018

Whatever is causing it, kantlipsum (also expl3, I believe) works fine.

@patta42

This comment has been minimized.

Copy link
Owner

patta42 commented Dec 25, 2018

It was easier than I thought. I haven't looked into the details of the two environments, but it seems they somehow scan for the occurrence of \par within their content. lipsum.sty, however, uses (not everywhere, there are some inconsistencies, I found out now) \tex_par:D instead of \par as recommended by the docs of latex3 (see interface3.pdf (describing release 2018/10/31), page 7, docs for package l3names).

I guess this is more an incompatibility of KOMA-Script and changepage with latex3 than a bug in lipsum, but I agree that this leads to highly unexpected results. So I guess I will patch it and release a next version (in a few days).

As long as the new version is not available, here is a workaround:

\documentclass{scrreprt}
\usepackage{changepage}
\usepackage{lipsum}

\SetLipsumParListItemSeparator{\par}

\begin{document}
  \begin{addmargin}[0pt]{.5\textwidth}
    \lipsum[1-3]
  \end{addmargin}

  \begin{adjustwidth}{0pt}{.5\textwidth}
    \lipsum[1-3]
  \end{adjustwidth}

\end{document}
@polysyllabic

This comment has been minimized.

Copy link

polysyllabic commented Dec 25, 2018

I believe they both use the traditional LaTeX2 trick of setting up a list to alter the indentation, so this same problem likely exists for any package that tries to use the same method.

@polysyllabic

This comment has been minimized.

Copy link

polysyllabic commented Dec 25, 2018

I just tested, and it looks like an interaction between \tex_par:D and the list environment. Using the expl3 version resets the left and right margins at least, and probably everything that's set in list's second parameter. Try this:

\documentclass{article}
\usepackage{xparse}
\usepackage{lipsum}

\ExplSyntaxOn
\NewDocumentCommand{\mypar} {} {\tex_par:D}
\ExplSyntaxOff

\begin{document}
\lipsum[1]  

\begin{list}{}{\setlength{\leftmargin}{2cm}\setlength{\rightmargin}{2cm}}
 \item Here's a paragraph with enough text that we can see where the line wraps.
 
 Here's another paragraph after a traditional paragraph break.
 
 Now we'll end this one with the expl3 version to see what happens next.\mypar
 And here's a forth to see where we are. The left and right margins are now disregarded.
\end{list}
\end{document}

I think this shows that it's actually expl3 that's the source of the problem, and only the LaTeX3 team will know if that's an intended side-effect or not.

@patta42

This comment has been minimized.

Copy link
Owner

patta42 commented Dec 25, 2018

The definition of the list environment is a quite complex monster in source2e, and I do not see where exactly the difference between using \par and \tex_par:D is, but I think you should notify the LaTeX3 team and file an issue. They still can decide that this is an intended side-effect.

@patta42

This comment has been minimized.

Copy link
Owner

patta42 commented Dec 25, 2018

The problem is that the list environment redefines \par, but (I guess) \tex_par:D is generated with \let:

\documentclass{article}

\let\mypar\par

\begin{document}

\begin{list}{}{\setlength{\leftmargin}{2cm}\setlength{\rightmargin}{2cm}}
 \item Here's a paragraph with enough text that we can see where the line wraps.
 
 Here's another paragraph after a traditional paragraph break.
 
 Now we'll end this one with the expl3 version to see what happens next.\mypar
 And here's a forth to see where we are. The left and right margins are now disregarded.
\end{list}
\end{document}
@patta42

This comment has been minimized.

Copy link
Owner

patta42 commented Dec 25, 2018

@patta42 patta42 closed this Dec 25, 2018

@patta42 patta42 added the bug label Dec 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment