2

I am not sure about the forum protocol regarding when to ask a new question and when to lump it in with an existing one, so I apologize if this is unorthodox. The question stems from ! Missing \endcsname inserted error when using \seq_map_pairwise_function:ccN. I have really just begun to explore expl3-style coding and I am far from a TeX guru, although I have been doing coding in other languages--obviously not typesetting languages--for many years. But the whole token/input stream methodology is a completely new paradigm for me and I am trying to wrap my head around it. The documentation is disseminated widely on the web, TeX books are few and getting harder to find (I actually bought Knuth's 5-volume set and Bechtolsheim's 4-volume set about a decade ago long before I got serious about this and they are currently in storage about a 1000 miles away), and I am consequently doing most of my learning by example, trial and error, and asking questions here. So please bear with me.

The code in the above reference has issues without the no-math option being passed to fontspec. Specifically, it has a problem with the common capital Greek letters having already been defined by fontspec. Now, including the no-math option indeed solves the problem, but I am more interested in why this is happening and why there is apparently no way to undefine or redefine commands in expl3. Or perhaps it is possible and I just haven't yet discovered how. So, this particular set of questions is independent of the above reference other than its having provided the example.

What does \cs_undefine do if not undefine a control sequence? What is its syntax? I cannot seem to make it work with \Gamma, for instance, regardless of whether I use :N or :c or \Gamma, {\Gamma}, or {Gamma}. The same is true for \cs_meaning, which I thought might help out with troubleshooting. I must be missing something fundamental. I am sure this could be done with plain TeX, but I get the impression from what I am reading that mixing the two is akin to dropping a self-modifying assembly routine into a C# UX application. Hypothetically, and regarding this specific case, if I could not use the no-math option, and the capital Greeks were already defined, how would I remedy the problem? More generally, how do you redefine a command that has already been defined with expl3? I'm probably not even asking the right questions, but I hope that someone will be able to see where I'm failing to grasp something and steer me in the right direction.

4
  • 2
    You may need to post a minimal working example. Commented Jul 23, 2023 at 22:31
  • 1
    It's not clear what you're trying to do. \documentclass{article} \ExplSyntaxOn \cs_undefine:N \Gamma \newcommand\Gamma{foo} \ExplSyntaxOff \begin{document} \Gamma \end{document} works as expected no?
    – Alan Munn
    Commented Jul 23, 2023 at 22:37
  • 1
    Similarly, the syntax for the csname version would be \cs_undefine:c {Gamma}.
    – Alan Munn
    Commented Jul 23, 2023 at 22:41
  • 2
    The command you are using \cs_set:Npx is \edef and will redefine commands, as I commented on your last question the error was not coming from your L3 code but from fontspec. Commented Jul 23, 2023 at 23:01

1 Answer 1

4

The message is completely unrelated to expl3 you have

\documentclass{article}
\usepackage
%[no-math]
{fontspec}

\def\Gamma{wibble}
\begin{document}

\end{document}

which produces

! LaTeX Error: Command `\Gamma' already defined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.7 \begin{document}
                  
?

as at \begin{document} fontspec tries to adjust some settings, using latex2e declarations that check commands are new.

no-math tells the package not to do that.

1
  • Sorry. I misinterpreted your comment in the other question to mean that fontspec was causing the problem because it had already defined these commands rather than that it was actually generating the errors because it was attempting to redefine them (which I am supposing it is doing in a \AtBeginDocument environment or similar construct).
    – Mike Pugh
    Commented Jul 24, 2023 at 6:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .