Skip to content
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

Drop unnecessary \@noitemerr in \addvspace and \addpenalty #1460

Open
FrankMittelbach opened this issue Sep 10, 2024 · 3 comments
Open

Drop unnecessary \@noitemerr in \addvspace and \addpenalty #1460

FrankMittelbach opened this issue Sep 10, 2024 · 3 comments
Assignees
Labels
category base (latex) enhancement fixed in dev Fixed in development branch, not in stable release

Comments

@FrankMittelbach
Copy link
Member

Brief outline of the enhancement

\addvspace and \addpenalty both call \@noitemerr if they are encountered in horizontal mode. This is really a leftover from the 2.09 days, i.e., more than 30 years old. Back then, this was necessary, because the list environments changed \parto do nothing when they started, thus calling \vskip (which is executedd by \addvspace) ended in a tight loop inserting \par over and over again without ever succeeding to reach vertical mode. In 2e this behavior was changed and \par got a definition that changed to vmode after 1000 unsuccessful attempts (and then issuing \@noitemerr) as well.

Thus, itis no longer necessary to generate this error in \addvspace and the only thing that it achieves today, is either an unnecessary error message (if the command is used outside a list) or generating the error message twice (if used inside a list).

It should therefore be taken out and instead \addvspaceshould instead simply issue a \par first before applying its logic.
This is upward compatible since no valid LaTeX document can call \addvspace in hmode right now.

Minimal example showing the current behaviour

\RequirePackage{latexbug}       % <--should be always the first line (see CONTRIBUTING)!
\documentclass{article}

\begin{document}

In vmode everything works:

\addvspace{1cm}

In hmode generates a no-item error and it should not  (in particular not this one which is bogus).
\addvspace{1cm}

\end{document}
@davidcarlisle
Copy link
Member

It would probably be worth noting in any ltnews description of this change that

\mbox{a\addvspace{1in}b}

would give a lower level ! Missing } inserted error now (unless we leave in the \ifvmode test and just remove \@noitemerr in which case it would be not an error at all, just ignored.

@FrankMittelbach
Copy link
Member Author

ah yes, because it still tries \vskip rather than wrapping it into a vadjust.
Maybe

\def\addvspace#1{%
  \ifhmode \ifinner \ERROR -in-box \else\par \fi \fi
  ...

@FrankMittelbach
Copy link
Member Author

By the way: is there any good reason why these two commands aren't robust? If I touch them then I could change that too, using \protected I guess

@FrankMittelbach FrankMittelbach added the fixed in dev Fixed in development branch, not in stable release label Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category base (latex) enhancement fixed in dev Fixed in development branch, not in stable release
Projects
Status: Done in dev
Development

No branches or pull requests

2 participants