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

Case Change Equivs break in \text_titlecase_first:n #1130

Closed
moewew opened this issue Sep 25, 2022 · 2 comments
Closed

Case Change Equivs break in \text_titlecase_first:n #1130

moewew opened this issue Sep 25, 2022 · 2 comments

Comments

@moewew
Copy link
Contributor

moewew commented Sep 25, 2022

Via plk/biblatex#1246

A command declared with \DeclareCaseChangeEquivalent breaks in \text_titlecase_first:n (which has no LaTeX2e equivalent as far as I can see)

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}

\usepackage{etoolbox}

\newrobustcmd*{\foo}[1]{foo|#1|}
\newrobustcmd*{\fooA}[1]{A|#1|}
\newrobustcmd*{\fooB}[1]{B|#1|}
\newrobustcmd*{\fooC}[1]{C|#1|}
\newrobustcmd*{\fooD}[1]{D|#1|}

\DeclareCaseChangeEquivalent{\foo}{%
  \CaseSwitch
    {\fooA}
    {\fooB}
    {\fooC}
    {\fooD}}

\begin{document}
\MakeUppercase{\foo{bar} foo}

\MakeLowercase{\foo{bar} foo}

\MakeTitlecase{\foo{bar} foo}

\ExplSyntaxOn
\text_lowercase:n {\foo{bar} foo}\par

\text_uppercase:n {\foo{bar} foo}\par

\text_titlecase:n {\foo{bar} foo}\par

\text_titlecase_first:n {\foo{bar} foo}
\ExplSyntaxOff

\end{document}

gives

! Missing number, treated as zero.
<to be read again> 
                   \__text_change_case_switch_titleonly:nnNnnnn 
l.34 \text_titlecase_first:n {\foo{bar} foo}

tested with

LaTeX2e <2022-06-01> patch level 5
L3 programming layer <2022-08-23>
@PhelypeOleinik
Copy link
Member

Providing the missing definition of \__text_change_case_switch_titleonly:nnNnnnn (seems like it should be equal to \__text_change_case_switch_title:nnNnnnn @josephwright?) should solve the problem:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\newrobustcmd*{\foo}[1]{foo|#1|}
\newrobustcmd*{\fooA}[1]{A|#1|}
\newrobustcmd*{\fooB}[1]{B|#1|}
\newrobustcmd*{\fooC}[1]{C|#1|}
\newrobustcmd*{\fooD}[1]{D|#1|}

\DeclareCaseChangeEquivalent{\foo}{%
  \CaseSwitch
    {\fooA}
    {\fooB}
    {\fooC}
    {\fooD}}

\begin{document}

\ExplSyntaxOn
\cs_new:Npn \__text_change_case_switch_titleonly:nnNnnnn #1#2#3#4#5#6#7
  {
    \__text_change_case_store:n {#7}
    \__text_change_case_loop:nnw {#1} {#2}
  }

\text_uppercase:n {\foo{bar} foo}\par

\text_lowercase:n {\foo{bar} foo}\par

\text_titlecase:n {\foo{bar} foo}\par

\text_titlecase_first:n {\foo{bar} foo}

\end{document}

@moewew
Copy link
Contributor Author

moewew commented Sep 26, 2022

That seems to work fine both in the example here as well as in the original biblatex MWE that sparked this report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants