babel + textcomp + redefining LaTeX
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
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.
documentclass[english]article
usepackagebabel
usepackagetextcomp
renewcommand*LaTeXhello
begindocument
Testing: LaTeX
enddocument
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.
babel textcomp
add a comment |Â
up vote
4
down vote
favorite
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.
documentclass[english]article
usepackagebabel
usepackagetextcomp
renewcommand*LaTeXhello
begindocument
Testing: LaTeX
enddocument
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.
babel textcomp
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
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.
documentclass[english]article
usepackagebabel
usepackagetextcomp
renewcommand*LaTeXhello
begindocument
Testing: LaTeX
enddocument
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.
babel textcomp
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.
documentclass[english]article
usepackagebabel
usepackagetextcomp
renewcommand*LaTeXhello
begindocument
Testing: LaTeX
enddocument
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.
babel textcomp
babel textcomp
asked 48 mins ago
John Palmieri
986715
986715
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
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:
newcommandBabelNonASCII % vvv Here's the one loaded by textcomp
LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU,TS1,T3,TS3
then it saves the original definitions of TeX
and LaTeX
:
letorg@TeXTeX
letorg@LaTeXLaTeX
letensureascii@firstofone
Now, when the begindocument
is executed, babel
checks if any of the encodings defined above were loaded:
AtBeginDocument%
in@false
bbl@foreachBabelNonASCII% is there a non-ascii enc?
ifin@else
lowercasebbl@xin@,#1enc.def,,@filelist,%
fi%
if any, then it redefines LaTeX
to be ensureasciiorg@LaTeX
(and a couple more things):
ifin@ % if a non-ascii has been loaded
defensureascii#1fontencodingOT1selectfont#1%
DeclareTextCommandDefaultTeXorg@TeX%
DeclareTextCommandDefaultLaTeXorg@LaTeX%
defbbl@tempb#1@@uppercasebbl@tempc#1ENC.DEF@empty@@%
defbbl@tempc#1ENC.DEF#2@@%
ifx@empty#2else
bbl@ifunsetT@#1%
%
bbl@xin@,#1,,BabelNonASCII,%
ifin@
DeclareTextCommandTeX#1ensureasciiorg@TeX%
DeclareTextCommandLaTeX#1ensureasciiorg@LaTeX%
else
defensureascii##1fontencoding#1selectfont##1%
fi%
fi%
bbl@foreach@filelistbbl@tempb#1@@% TODO - @@ de mas??
bbl@xin@,cf@encoding,,BabelNonASCII,%
ifin@else
edefensureascii#1%
noexpandfontencodingcf@encodingnoexpandselectfont#1%
fi
fi
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 begindocument
, or AtBeginDocument
after babel
is loaded:
documentclassarticle
% renewcommand*LaTeXhello % Option 1
usepackagebabel
usepackagetextcomp
% AtBeginDocumentrenewcommand*LaTeXhello % Option 2
begindocument
% renewcommand*LaTeXhello % Option 3
Testing: LaTeX
enddocument
Option 1 works because when
babel
is loaded,LaTeX
ishello
, soorg@LaTeX
becomeshello
and your definition is used.Option 2 works because the
AtBeginDocument
command adds the argument to the end of the token list, so your redefinition is executed afterbabel
's. It is essentially the same as doing it after theBeginDocument
.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`:
% changesbabel~3.232018/08/28Added 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.
â John Palmieri
14 mins ago
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 ofbabel
...
â Phelype Oleinik
6 mins ago
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
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:
newcommandBabelNonASCII % vvv Here's the one loaded by textcomp
LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU,TS1,T3,TS3
then it saves the original definitions of TeX
and LaTeX
:
letorg@TeXTeX
letorg@LaTeXLaTeX
letensureascii@firstofone
Now, when the begindocument
is executed, babel
checks if any of the encodings defined above were loaded:
AtBeginDocument%
in@false
bbl@foreachBabelNonASCII% is there a non-ascii enc?
ifin@else
lowercasebbl@xin@,#1enc.def,,@filelist,%
fi%
if any, then it redefines LaTeX
to be ensureasciiorg@LaTeX
(and a couple more things):
ifin@ % if a non-ascii has been loaded
defensureascii#1fontencodingOT1selectfont#1%
DeclareTextCommandDefaultTeXorg@TeX%
DeclareTextCommandDefaultLaTeXorg@LaTeX%
defbbl@tempb#1@@uppercasebbl@tempc#1ENC.DEF@empty@@%
defbbl@tempc#1ENC.DEF#2@@%
ifx@empty#2else
bbl@ifunsetT@#1%
%
bbl@xin@,#1,,BabelNonASCII,%
ifin@
DeclareTextCommandTeX#1ensureasciiorg@TeX%
DeclareTextCommandLaTeX#1ensureasciiorg@LaTeX%
else
defensureascii##1fontencoding#1selectfont##1%
fi%
fi%
bbl@foreach@filelistbbl@tempb#1@@% TODO - @@ de mas??
bbl@xin@,cf@encoding,,BabelNonASCII,%
ifin@else
edefensureascii#1%
noexpandfontencodingcf@encodingnoexpandselectfont#1%
fi
fi
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 begindocument
, or AtBeginDocument
after babel
is loaded:
documentclassarticle
% renewcommand*LaTeXhello % Option 1
usepackagebabel
usepackagetextcomp
% AtBeginDocumentrenewcommand*LaTeXhello % Option 2
begindocument
% renewcommand*LaTeXhello % Option 3
Testing: LaTeX
enddocument
Option 1 works because when
babel
is loaded,LaTeX
ishello
, soorg@LaTeX
becomeshello
and your definition is used.Option 2 works because the
AtBeginDocument
command adds the argument to the end of the token list, so your redefinition is executed afterbabel
's. It is essentially the same as doing it after theBeginDocument
.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`:
% changesbabel~3.232018/08/28Added 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.
â John Palmieri
14 mins ago
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 ofbabel
...
â Phelype Oleinik
6 mins ago
add a comment |Â
up vote
3
down vote
accepted
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:
newcommandBabelNonASCII % vvv Here's the one loaded by textcomp
LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU,TS1,T3,TS3
then it saves the original definitions of TeX
and LaTeX
:
letorg@TeXTeX
letorg@LaTeXLaTeX
letensureascii@firstofone
Now, when the begindocument
is executed, babel
checks if any of the encodings defined above were loaded:
AtBeginDocument%
in@false
bbl@foreachBabelNonASCII% is there a non-ascii enc?
ifin@else
lowercasebbl@xin@,#1enc.def,,@filelist,%
fi%
if any, then it redefines LaTeX
to be ensureasciiorg@LaTeX
(and a couple more things):
ifin@ % if a non-ascii has been loaded
defensureascii#1fontencodingOT1selectfont#1%
DeclareTextCommandDefaultTeXorg@TeX%
DeclareTextCommandDefaultLaTeXorg@LaTeX%
defbbl@tempb#1@@uppercasebbl@tempc#1ENC.DEF@empty@@%
defbbl@tempc#1ENC.DEF#2@@%
ifx@empty#2else
bbl@ifunsetT@#1%
%
bbl@xin@,#1,,BabelNonASCII,%
ifin@
DeclareTextCommandTeX#1ensureasciiorg@TeX%
DeclareTextCommandLaTeX#1ensureasciiorg@LaTeX%
else
defensureascii##1fontencoding#1selectfont##1%
fi%
fi%
bbl@foreach@filelistbbl@tempb#1@@% TODO - @@ de mas??
bbl@xin@,cf@encoding,,BabelNonASCII,%
ifin@else
edefensureascii#1%
noexpandfontencodingcf@encodingnoexpandselectfont#1%
fi
fi
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 begindocument
, or AtBeginDocument
after babel
is loaded:
documentclassarticle
% renewcommand*LaTeXhello % Option 1
usepackagebabel
usepackagetextcomp
% AtBeginDocumentrenewcommand*LaTeXhello % Option 2
begindocument
% renewcommand*LaTeXhello % Option 3
Testing: LaTeX
enddocument
Option 1 works because when
babel
is loaded,LaTeX
ishello
, soorg@LaTeX
becomeshello
and your definition is used.Option 2 works because the
AtBeginDocument
command adds the argument to the end of the token list, so your redefinition is executed afterbabel
's. It is essentially the same as doing it after theBeginDocument
.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`:
% changesbabel~3.232018/08/28Added 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.
â John Palmieri
14 mins ago
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 ofbabel
...
â Phelype Oleinik
6 mins ago
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
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:
newcommandBabelNonASCII % vvv Here's the one loaded by textcomp
LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU,TS1,T3,TS3
then it saves the original definitions of TeX
and LaTeX
:
letorg@TeXTeX
letorg@LaTeXLaTeX
letensureascii@firstofone
Now, when the begindocument
is executed, babel
checks if any of the encodings defined above were loaded:
AtBeginDocument%
in@false
bbl@foreachBabelNonASCII% is there a non-ascii enc?
ifin@else
lowercasebbl@xin@,#1enc.def,,@filelist,%
fi%
if any, then it redefines LaTeX
to be ensureasciiorg@LaTeX
(and a couple more things):
ifin@ % if a non-ascii has been loaded
defensureascii#1fontencodingOT1selectfont#1%
DeclareTextCommandDefaultTeXorg@TeX%
DeclareTextCommandDefaultLaTeXorg@LaTeX%
defbbl@tempb#1@@uppercasebbl@tempc#1ENC.DEF@empty@@%
defbbl@tempc#1ENC.DEF#2@@%
ifx@empty#2else
bbl@ifunsetT@#1%
%
bbl@xin@,#1,,BabelNonASCII,%
ifin@
DeclareTextCommandTeX#1ensureasciiorg@TeX%
DeclareTextCommandLaTeX#1ensureasciiorg@LaTeX%
else
defensureascii##1fontencoding#1selectfont##1%
fi%
fi%
bbl@foreach@filelistbbl@tempb#1@@% TODO - @@ de mas??
bbl@xin@,cf@encoding,,BabelNonASCII,%
ifin@else
edefensureascii#1%
noexpandfontencodingcf@encodingnoexpandselectfont#1%
fi
fi
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 begindocument
, or AtBeginDocument
after babel
is loaded:
documentclassarticle
% renewcommand*LaTeXhello % Option 1
usepackagebabel
usepackagetextcomp
% AtBeginDocumentrenewcommand*LaTeXhello % Option 2
begindocument
% renewcommand*LaTeXhello % Option 3
Testing: LaTeX
enddocument
Option 1 works because when
babel
is loaded,LaTeX
ishello
, soorg@LaTeX
becomeshello
and your definition is used.Option 2 works because the
AtBeginDocument
command adds the argument to the end of the token list, so your redefinition is executed afterbabel
's. It is essentially the same as doing it after theBeginDocument
.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`:
% changesbabel~3.232018/08/28Added TS1, T3, TS3
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:
newcommandBabelNonASCII % vvv Here's the one loaded by textcomp
LGR,X2,OT2,OT3,OT6,LHE,LWN,LMA,LMC,LMS,LMU,TS1,T3,TS3
then it saves the original definitions of TeX
and LaTeX
:
letorg@TeXTeX
letorg@LaTeXLaTeX
letensureascii@firstofone
Now, when the begindocument
is executed, babel
checks if any of the encodings defined above were loaded:
AtBeginDocument%
in@false
bbl@foreachBabelNonASCII% is there a non-ascii enc?
ifin@else
lowercasebbl@xin@,#1enc.def,,@filelist,%
fi%
if any, then it redefines LaTeX
to be ensureasciiorg@LaTeX
(and a couple more things):
ifin@ % if a non-ascii has been loaded
defensureascii#1fontencodingOT1selectfont#1%
DeclareTextCommandDefaultTeXorg@TeX%
DeclareTextCommandDefaultLaTeXorg@LaTeX%
defbbl@tempb#1@@uppercasebbl@tempc#1ENC.DEF@empty@@%
defbbl@tempc#1ENC.DEF#2@@%
ifx@empty#2else
bbl@ifunsetT@#1%
%
bbl@xin@,#1,,BabelNonASCII,%
ifin@
DeclareTextCommandTeX#1ensureasciiorg@TeX%
DeclareTextCommandLaTeX#1ensureasciiorg@LaTeX%
else
defensureascii##1fontencoding#1selectfont##1%
fi%
fi%
bbl@foreach@filelistbbl@tempb#1@@% TODO - @@ de mas??
bbl@xin@,cf@encoding,,BabelNonASCII,%
ifin@else
edefensureascii#1%
noexpandfontencodingcf@encodingnoexpandselectfont#1%
fi
fi
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 begindocument
, or AtBeginDocument
after babel
is loaded:
documentclassarticle
% renewcommand*LaTeXhello % Option 1
usepackagebabel
usepackagetextcomp
% AtBeginDocumentrenewcommand*LaTeXhello % Option 2
begindocument
% renewcommand*LaTeXhello % Option 3
Testing: LaTeX
enddocument
Option 1 works because when
babel
is loaded,LaTeX
ishello
, soorg@LaTeX
becomeshello
and your definition is used.Option 2 works because the
AtBeginDocument
command adds the argument to the end of the token list, so your redefinition is executed afterbabel
's. It is essentially the same as doing it after theBeginDocument
.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`:
% changesbabel~3.232018/08/28Added TS1, T3, TS3
edited 17 mins ago
answered 22 mins ago
Phelype Oleinik
19.4k54275
19.4k54275
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.
â John Palmieri
14 mins ago
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 ofbabel
...
â Phelype Oleinik
6 mins ago
add a comment |Â
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.
â John Palmieri
14 mins ago
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 ofbabel
...
â Phelype Oleinik
6 mins ago
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.
â John Palmieri
14 mins ago
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.
â John Palmieri
14 mins ago
1
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
...â Phelype Oleinik
6 mins ago
@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
...â Phelype Oleinik
6 mins ago
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f456959%2fbabel-textcomp-redefining-latex%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password