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

\AddToNoCaseChangeList not working #904

Closed
mrpiggi opened this issue Aug 3, 2022 · 21 comments
Closed

\AddToNoCaseChangeList not working #904

mrpiggi opened this issue Aug 3, 2022 · 21 comments

Comments

@mrpiggi
Copy link

mrpiggi commented Aug 3, 2022

Brief outline of the bug

Either using pdflatex or lualatex both with the stable and the development version, \AddToNoCaseChangeList has no effect, although it's argument is added to \l_text_case_exclude_arg_tl.

Minimal example showing the bug

\listfiles
\RequirePackage{latexbug}
\documentclass{article}
\begin{document}
\def\DontChangeCase#1{\textit{#1}}
\MakeUppercase{This is \NoCaseChange{\DontChangeCase{obviously}} working.}
\AddToNoCaseChangeList{\DontChangeCase}
\MakeUppercase{This is \DontChangeCase{not} working!}

\expandafter\show\csname l_text_case_exclude_arg_tl\endcsname
\end{document}

Log file (required) and possibly PDF file

changecase.log

@davidcarlisle
Copy link
Member

We should probably highlight this more, but the command needs to be protected

\documentclass{article}
\begin{document}
\protected\def\DontChangeCase#1{\textit{#1}}
\MakeUppercase{This is \NoCaseChange{\DontChangeCase{obviously}} working.}
\AddToNoCaseChangeList{\DontChangeCase}
\MakeUppercase{This is \DontChangeCase{not} working!}

\expandafter\show\csname l_text_case_exclude_arg_tl\endcsname
\end{document}

@FrankMittelbach
Copy link
Member

or even test for the condition in \AddToNoCaseList as this is an easy to make user error.

@FrankMittelbach FrankMittelbach added this to Pool (unscheduled issues) in upcoming LaTeX2e releases via automation Aug 3, 2022
@FrankMittelbach FrankMittelbach added this to the Release 2022 Fall milestone Aug 3, 2022
@josephwright
Copy link
Member

I guess because I always recommend document commands are protected I forgot about this. We could adjust such ath commands are added to the 'no expand' list too: that would avoid the issue.

@davidcarlisle
Copy link
Member

@josephwright you mean support un \protected commands, as in the original example here?

@josephwright
Copy link
Member

@davidcarlisle Yes

@FrankMittelbach
Copy link
Member

but they are added, they are only not looked at because the expand away first or am I missing something?

@josephwright
Copy link
Member

@FrankMittelbach I meant that expandable commands need to be in \l_text_expand_exclude_tl to avoid 'disappearing' in \text_expand:n, which all of the other \text... functions use up-front.

@FrankMittelbach
Copy link
Member

@josephwright and that has no unwanted side effects in that just because you add a command to the "don't casechange" it suddenly stops expanding elsewhere?

@josephwright
Copy link
Member

@FrankMittelbach There should not be, no

@FrankMittelbach
Copy link
Member

@josephwright sorry, don't get it. \text_expand:n could be used in other places and there the expandable command added to \l_text_expand_exclude_tl would no longer expand or not? And that would be wrong just because I don't want it to expand in a case changer.

@josephwright
Copy link
Member

@FrankMittelbach The idea of \l_text_expand_exclude_tl is to list things that 'look expandable' but should not be expanded. So when we apply \text_expand:n, anything in \l_text_expand_exclude_tl is left alone. What happens next is down to the consumer command, but typically I'd expect entries there to be no-ops in the general situation. So for example \NoCaseChange can be defined \def\NoCaseChange#1{#1} and appear in \l_text_expand_exclude_tl: in the case changer this token can then be picked up, in other places the fact it's not been 'expanded away' will not make a difference.

@davidcarlisle
Copy link
Member

@josephwright I'm not sure I see that? if I have \def\Name#1{<#1>} and add it to No case change list, I may still want this to be expanded out by \text_expand:n for other contexts such as text purification, Of course depending on the consuming code such an expandable command may "just work" and so having it unexpanded may not be an issue, but it does seem to be a change.

@josephwright
Copy link
Member

@davidcarlisle That's what I meant by 'consumer': \text_purify:n does exactly that, for example

@mrpiggi
Copy link
Author

mrpiggi commented Aug 4, 2022

If the command in question must be protected, what about \AddToNoCaseChangeList{\thanks}? In general, if I wanted to use \AddToNoCaseChangeList with a command either from the kernel or a third-party package, it would be really a pain to search for it's definition and apply for example \robustify from etoolbox. Especially, if unwanted side-effects could occur by doing so.

@u-fischer
Copy link
Member

\thanks is robust and it works:

\documentclass{jacow}
\AddToNoCaseChangeList{\thanks}
\begin{document}

\title{An outstanding Paper%
                \thanks{No funding for this paper}}

\author{A. N. Author, City, State, Country}

\maketitle

\end{document}

@mrpiggi
Copy link
Author

mrpiggi commented Aug 4, 2022

\thanks is robust and it works:

Sorry, my bad. I tested with my classes where I redefined \thanks locally. Nevertheless, it would be very convenient, if AddToNoCaseChangeList could be used not only with protected commands.

BTW: Although it was quite hacky, previous it was possible to suppress case changing for a command with any arbitrary arguments by patching \@uclcnotmath. This is not possible anymore, right?

@davidcarlisle
Copy link
Member

@mrpiggi you can (locally if necessary) define the command as something like \def\foo#1#2#3{\NoCaseChange{\realfoo{#1}{#2}{#3}}} which will make the three argument \foo grab all three arguments and guard them from the case changer.

@josephwright josephwright self-assigned this Nov 8, 2022
@josephwright josephwright modified the milestones: Release 2022 Fall, Release 2023 Spring Nov 8, 2022
@josephwright
Copy link
Member

OK, we have two possible approaches:

  1. Adjust \AddToNoCaseChangeList so it also adds to \l_text_expand_exclude_tl
  2. Document that commands used here have to be robust

Preferences?

@stale
Copy link

stale bot commented Jan 7, 2023

This issue has been automatically marked as stale because it has not had recent activity.

@stale stale bot added the stale label Jan 7, 2023
@stale stale bot removed the stale label Jun 8, 2023
@stale stale bot removed the stale label Jun 8, 2023
@josephwright
Copy link
Member

I've thought about this again: I'm going to fix from expl3.

@josephwright
Copy link
Member

I'll close here once the next l3kernel release goes out (it will not need to wait for the Fall 2023 LaTeX2e release: once expl3 changes it will 'just happen').

upcoming LaTeX2e releases automation moved this from Pool (unscheduled issues) to Done Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

5 participants