I see this with TeXLive 2018, which includes version 3.26 of babel.sty (2018/10/16 3.26"). I think this works with some earlier versions of babel.sty, but I'm not sure where the cutoff is.


Testing: \LaTeX


When I run PDFLaTeX on this, I do not see "Testing: hello" but instead see "Testing: LaTeX". Why can't I redefine the macro \LaTeX?

Note that I only see the problem if I use both packages babel and textcomp; omit either and things work as they should.

1 Answer 1


This happens because textcomp loads a non-ASCII encoding (ts1enc.def), and babel explicitly checks for that and, if that's the case, it changes the definition of the \LaTeX macro. The relevant part of the file:

When babel is being loaded it defines the list of non-ASCII encodings:

\newcommand\BabelNonASCII %                   vvv Here's the one loaded by textcomp

then it saves the original definitions of \TeX and \LaTeX:


Now, when the \begin{document} is executed, babel checks if any of the encodings defined above were loaded:

  \bbl@foreach\BabelNonASCII{% is there a non-ascii enc?

if any, then it redefines \LaTeX to be \ensureascii{\org@LaTeX} (and a couple more things):

  \ifin@ % if a non-ascii has been loaded
    \bbl@foreach\@filelist{\bbl@tempb#1\@@}%  TODO - \@@ de mas??

The problem is that \org@LaTeX is defined when babel is loaded, and \LaTeX is _re_defined \AtBeginDocument, so your \renewcommand is overwritten.

To overcome this you'll need to redefine \LaTeX either before babel is loaded, after the \begin{document}, or \AtBeginDocument after babel is loaded:

% \renewcommand*{\LaTeX}{hello} % Option 1
% \AtBeginDocument{\renewcommand*{\LaTeX}{hello}} % Option 2
% \renewcommand*{\LaTeX}{hello} % Option 3

Testing: \LaTeX

  1. Option 1 works because when babel is loaded, \LaTeX is hello, so \org@LaTeX becomes hello and your definition is used.

  2. Option 2 works because the \AtBeginDocument command adds the argument to the end of the token list, so your redefinition is executed after babel's. It is essentially the same as doing it after the \BeginDocument.

  3. Option 3 trivially works because nothing happens between your redefinition and the usage of the command.

This change happened in babel version 3.23, when the encodings TS1, T3, TS3 were added to the non-ASCII list:

% Line 8996 of an up-to-date (26-10-2018) `babel.dtx`:
% \changes{babel~3.23}{2018/08/28}{Added TS1, T3, TS3}
  • This is very helpful. This is presumably not a bug (right?), but as you point out, it is new behavior. In my case, I am dealing with a partially autogenerated LaTeX file, via Sphinx, and I think option 2 will work. Oct 26, 2018 at 20:53
  • 1
    @JohnPalmieri It's documented so it's certainly not a bug. According to the documentation it's introduced to fix a bug when using other scripts (section 1.20 Selecting scripts). I couldn't yet manage to reproduce the bug with an older version of babel... Oct 26, 2018 at 21:01
  • 2
    There was a bug, indeed, but the fix is not correct either. I'll fix it. Oct 28, 2018 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.