Change the catcode and then define a (Unicode) character
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
The motivation is that I sometimes have, e.g.
% !TEX encoding = UTF-8 Unicode
catcode`ï=active
defï#1#2overline#1#2
$ïab+ïbc=ïac$
in my code.
I thought it would be nice if there is a macro, say activatedefine
,
such that
activatedefineï#1#2overline#1#2
does the job that catcode
and def
do.
I understand that it is not correct to write
defactivatedefine#1
catcode`#1=active
def#1
because the catcode of the #1
in the third line is not changed.
But then I hear that futurelet
can duplicate tokens.
So I came up with
defactivatedefine
futureletthecharnowwecanplaywiththechar
defnowwecanplaywiththechar
expandaftercatcodeexpandafter`thechar=13
def
This is still not quite right because thechar
does not expand to ï
.
So I try to fix it
defactivatedefine
futureletthecharnowwecanplaywiththechar
defgobbletwo#1 #2
defnowwecanplaywiththechar
edefactivatethechar
noexpandcatcode`expandaftergobbletwomeaningthechar=active
%message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
%message^^J The catcode becomes thecatcode`ï^^J^^J
def
activatedefineï#1#2overline#1#2
This macro does change the catcode of ï
to 13
.
But TeX complains Missing control sequence inserted
.
What is going wrong with my code?
Edit
Almost forgot MWE
% !TEX TS-program = XeLaTeX
% !TEX encoding = UTF-8 Unicode
documentclassarticle
begindocument
defactivatedefinefutureletthecharnowwecanplaywiththechar
%defnowwecanplaywiththechar
% expandaftercatcodeexpandafter`thechar=13
% def
%
defgobbletwo#1 #2
defnowwecanplaywiththechar%
edefactivatethechar%
noexpandcatcode`expandaftergobbletwomeaningthechar=active
message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
message^^J The catcode becomes thecatcode`ï^^J^^J
defï
activatedefineï#1#2overline#1#2
enddocument
xetex luatex catcodes
 |Â
show 4 more comments
up vote
3
down vote
favorite
The motivation is that I sometimes have, e.g.
% !TEX encoding = UTF-8 Unicode
catcode`ï=active
defï#1#2overline#1#2
$ïab+ïbc=ïac$
in my code.
I thought it would be nice if there is a macro, say activatedefine
,
such that
activatedefineï#1#2overline#1#2
does the job that catcode
and def
do.
I understand that it is not correct to write
defactivatedefine#1
catcode`#1=active
def#1
because the catcode of the #1
in the third line is not changed.
But then I hear that futurelet
can duplicate tokens.
So I came up with
defactivatedefine
futureletthecharnowwecanplaywiththechar
defnowwecanplaywiththechar
expandaftercatcodeexpandafter`thechar=13
def
This is still not quite right because thechar
does not expand to ï
.
So I try to fix it
defactivatedefine
futureletthecharnowwecanplaywiththechar
defgobbletwo#1 #2
defnowwecanplaywiththechar
edefactivatethechar
noexpandcatcode`expandaftergobbletwomeaningthechar=active
%message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
%message^^J The catcode becomes thecatcode`ï^^J^^J
def
activatedefineï#1#2overline#1#2
This macro does change the catcode of ï
to 13
.
But TeX complains Missing control sequence inserted
.
What is going wrong with my code?
Edit
Almost forgot MWE
% !TEX TS-program = XeLaTeX
% !TEX encoding = UTF-8 Unicode
documentclassarticle
begindocument
defactivatedefinefutureletthecharnowwecanplaywiththechar
%defnowwecanplaywiththechar
% expandaftercatcodeexpandafter`thechar=13
% def
%
defgobbletwo#1 #2
defnowwecanplaywiththechar%
edefactivatethechar%
noexpandcatcode`expandaftergobbletwomeaningthechar=active
message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
message^^J The catcode becomes thecatcode`ï^^J^^J
defï
activatedefineï#1#2overline#1#2
enddocument
xetex luatex catcodes
usingfuturelet
will freeze the catcode of the next token (the one to which the macro is let). This may or not be relevant to your problems (I admit not having read in detail).
â jfbu
37 mins ago
It's not a good idea to make the back quote active.
â egreg
30 mins ago
also what do you mean by Uniocde here? if you are using pdftex you can only define single byte tokens this way not arbitrary unicode characters.
â David Carlisle
27 mins ago
@jfbu Thatfuturelet
will freeze the catcode is unexpected (by me). That answers why TeX complains.
â Symbol 1
25 mins ago
@egreg I did not want to make back quote active. If my code did that it is unintended. I (only) want to make non-ASCII characters active.
â Symbol 1
23 mins ago
 |Â
show 4 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
The motivation is that I sometimes have, e.g.
% !TEX encoding = UTF-8 Unicode
catcode`ï=active
defï#1#2overline#1#2
$ïab+ïbc=ïac$
in my code.
I thought it would be nice if there is a macro, say activatedefine
,
such that
activatedefineï#1#2overline#1#2
does the job that catcode
and def
do.
I understand that it is not correct to write
defactivatedefine#1
catcode`#1=active
def#1
because the catcode of the #1
in the third line is not changed.
But then I hear that futurelet
can duplicate tokens.
So I came up with
defactivatedefine
futureletthecharnowwecanplaywiththechar
defnowwecanplaywiththechar
expandaftercatcodeexpandafter`thechar=13
def
This is still not quite right because thechar
does not expand to ï
.
So I try to fix it
defactivatedefine
futureletthecharnowwecanplaywiththechar
defgobbletwo#1 #2
defnowwecanplaywiththechar
edefactivatethechar
noexpandcatcode`expandaftergobbletwomeaningthechar=active
%message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
%message^^J The catcode becomes thecatcode`ï^^J^^J
def
activatedefineï#1#2overline#1#2
This macro does change the catcode of ï
to 13
.
But TeX complains Missing control sequence inserted
.
What is going wrong with my code?
Edit
Almost forgot MWE
% !TEX TS-program = XeLaTeX
% !TEX encoding = UTF-8 Unicode
documentclassarticle
begindocument
defactivatedefinefutureletthecharnowwecanplaywiththechar
%defnowwecanplaywiththechar
% expandaftercatcodeexpandafter`thechar=13
% def
%
defgobbletwo#1 #2
defnowwecanplaywiththechar%
edefactivatethechar%
noexpandcatcode`expandaftergobbletwomeaningthechar=active
message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
message^^J The catcode becomes thecatcode`ï^^J^^J
defï
activatedefineï#1#2overline#1#2
enddocument
xetex luatex catcodes
The motivation is that I sometimes have, e.g.
% !TEX encoding = UTF-8 Unicode
catcode`ï=active
defï#1#2overline#1#2
$ïab+ïbc=ïac$
in my code.
I thought it would be nice if there is a macro, say activatedefine
,
such that
activatedefineï#1#2overline#1#2
does the job that catcode
and def
do.
I understand that it is not correct to write
defactivatedefine#1
catcode`#1=active
def#1
because the catcode of the #1
in the third line is not changed.
But then I hear that futurelet
can duplicate tokens.
So I came up with
defactivatedefine
futureletthecharnowwecanplaywiththechar
defnowwecanplaywiththechar
expandaftercatcodeexpandafter`thechar=13
def
This is still not quite right because thechar
does not expand to ï
.
So I try to fix it
defactivatedefine
futureletthecharnowwecanplaywiththechar
defgobbletwo#1 #2
defnowwecanplaywiththechar
edefactivatethechar
noexpandcatcode`expandaftergobbletwomeaningthechar=active
%message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
%message^^J The catcode becomes thecatcode`ï^^J^^J
def
activatedefineï#1#2overline#1#2
This macro does change the catcode of ï
to 13
.
But TeX complains Missing control sequence inserted
.
What is going wrong with my code?
Edit
Almost forgot MWE
% !TEX TS-program = XeLaTeX
% !TEX encoding = UTF-8 Unicode
documentclassarticle
begindocument
defactivatedefinefutureletthecharnowwecanplaywiththechar
%defnowwecanplaywiththechar
% expandaftercatcodeexpandafter`thechar=13
% def
%
defgobbletwo#1 #2
defnowwecanplaywiththechar%
edefactivatethechar%
noexpandcatcode`expandaftergobbletwomeaningthechar=active
message^^J^^J stringactivatethechar is meaningactivatethechar
activatethechar
message^^J The catcode becomes thecatcode`ï^^J^^J
defï
activatedefineï#1#2overline#1#2
enddocument
xetex luatex catcodes
xetex luatex catcodes
edited 15 mins ago
asked 41 mins ago
Symbol 1
24k235111
24k235111
usingfuturelet
will freeze the catcode of the next token (the one to which the macro is let). This may or not be relevant to your problems (I admit not having read in detail).
â jfbu
37 mins ago
It's not a good idea to make the back quote active.
â egreg
30 mins ago
also what do you mean by Uniocde here? if you are using pdftex you can only define single byte tokens this way not arbitrary unicode characters.
â David Carlisle
27 mins ago
@jfbu Thatfuturelet
will freeze the catcode is unexpected (by me). That answers why TeX complains.
â Symbol 1
25 mins ago
@egreg I did not want to make back quote active. If my code did that it is unintended. I (only) want to make non-ASCII characters active.
â Symbol 1
23 mins ago
 |Â
show 4 more comments
usingfuturelet
will freeze the catcode of the next token (the one to which the macro is let). This may or not be relevant to your problems (I admit not having read in detail).
â jfbu
37 mins ago
It's not a good idea to make the back quote active.
â egreg
30 mins ago
also what do you mean by Uniocde here? if you are using pdftex you can only define single byte tokens this way not arbitrary unicode characters.
â David Carlisle
27 mins ago
@jfbu Thatfuturelet
will freeze the catcode is unexpected (by me). That answers why TeX complains.
â Symbol 1
25 mins ago
@egreg I did not want to make back quote active. If my code did that it is unintended. I (only) want to make non-ASCII characters active.
â Symbol 1
23 mins ago
using
futurelet
will freeze the catcode of the next token (the one to which the macro is let). This may or not be relevant to your problems (I admit not having read in detail).â jfbu
37 mins ago
using
futurelet
will freeze the catcode of the next token (the one to which the macro is let). This may or not be relevant to your problems (I admit not having read in detail).â jfbu
37 mins ago
It's not a good idea to make the back quote active.
â egreg
30 mins ago
It's not a good idea to make the back quote active.
â egreg
30 mins ago
also what do you mean by Uniocde here? if you are using pdftex you can only define single byte tokens this way not arbitrary unicode characters.
â David Carlisle
27 mins ago
also what do you mean by Uniocde here? if you are using pdftex you can only define single byte tokens this way not arbitrary unicode characters.
â David Carlisle
27 mins ago
@jfbu That
futurelet
will freeze the catcode is unexpected (by me). That answers why TeX complains.â Symbol 1
25 mins ago
@jfbu That
futurelet
will freeze the catcode is unexpected (by me). That answers why TeX complains.â Symbol 1
25 mins ago
@egreg I did not want to make back quote active. If my code did that it is unintended. I (only) want to make non-ASCII characters active.
â Symbol 1
23 mins ago
@egreg I did not want to make back quote active. If my code did that it is unintended. I (only) want to make non-ASCII characters active.
â Symbol 1
23 mins ago
 |Â
show 4 more comments
2 Answers
2
active
oldest
votes
up vote
4
down vote
accepted
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupdef~%
activatedefineï#1#2overline#1#2
begindocument
$ïab+ïbc=ïac$
enddocument
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefine|#1#2overline#1#2
begindocument
$|ab+|bc=|ac$
enddocument
I did not pay much attention to the actual macro, which is in math mode so math active would be possibly better.
Besides I don't want to have to handle UTF-8, so I used |
rather for the example.
AH! but OP is using XeTeX. So we can do this
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefineï#1#2overline#1#2
begindocument
thecatcode`ï % ONLY XETEX, NOT PDFTEX!
$ïab+ïbc=ïac$
enddocument
% Local variables:
% TeX-engine: xetex
% End:
Problem with pdflatex is that ï
is multibyte, and the erased code at top of my answer was redefinig the first byte, breaking LaTeX UTF-8.
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting thatlowercase
will reevaluate the catcode of¯
?
â Symbol 1
16 mins ago
The tilde is active. Thelowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.
â jfbu
13 mins ago
@jfbu Where can I find the exact behavior oflowercase
, including what you just said? Why on earth canlowercase
contains assignments... This blows my mind.
â Symbol 1
3 mins ago
TeX by Topic3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site foregreg+lowercase
for many many examples.
â jfbu
2 mins ago
add a comment |Â
up vote
2
down vote
The simplest way is to use newunicodechar
; it just defines parameterless macros, but we can exploit the fact TeX is a macro expansion language to begin with.
Note that these examples can be used with all TeX engines (except Knuth TeX).
documentclassarticle
usepackagenewunicodechar
newunicodecharâ¾overline
newcommandtwooverline[2]overline#1#2
newunicodecharï¹Âtwooverline
begindocument
$â¾a$ $ï¹Âab$
enddocument
Another example:
documentclassarticle
usepackagenewunicodechar
makeatletter
newunicodecharâ¾symbol@overline
defsymbol@overline#1â¾overline#1 % must go second
begindocument
$â¾abcâ¾$
enddocument
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupdef~%
activatedefineï#1#2overline#1#2
begindocument
$ïab+ïbc=ïac$
enddocument
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefine|#1#2overline#1#2
begindocument
$|ab+|bc=|ac$
enddocument
I did not pay much attention to the actual macro, which is in math mode so math active would be possibly better.
Besides I don't want to have to handle UTF-8, so I used |
rather for the example.
AH! but OP is using XeTeX. So we can do this
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefineï#1#2overline#1#2
begindocument
thecatcode`ï % ONLY XETEX, NOT PDFTEX!
$ïab+ïbc=ïac$
enddocument
% Local variables:
% TeX-engine: xetex
% End:
Problem with pdflatex is that ï
is multibyte, and the erased code at top of my answer was redefinig the first byte, breaking LaTeX UTF-8.
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting thatlowercase
will reevaluate the catcode of¯
?
â Symbol 1
16 mins ago
The tilde is active. Thelowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.
â jfbu
13 mins ago
@jfbu Where can I find the exact behavior oflowercase
, including what you just said? Why on earth canlowercase
contains assignments... This blows my mind.
â Symbol 1
3 mins ago
TeX by Topic3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site foregreg+lowercase
for many many examples.
â jfbu
2 mins ago
add a comment |Â
up vote
4
down vote
accepted
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupdef~%
activatedefineï#1#2overline#1#2
begindocument
$ïab+ïbc=ïac$
enddocument
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefine|#1#2overline#1#2
begindocument
$|ab+|bc=|ac$
enddocument
I did not pay much attention to the actual macro, which is in math mode so math active would be possibly better.
Besides I don't want to have to handle UTF-8, so I used |
rather for the example.
AH! but OP is using XeTeX. So we can do this
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefineï#1#2overline#1#2
begindocument
thecatcode`ï % ONLY XETEX, NOT PDFTEX!
$ïab+ïbc=ïac$
enddocument
% Local variables:
% TeX-engine: xetex
% End:
Problem with pdflatex is that ï
is multibyte, and the erased code at top of my answer was redefinig the first byte, breaking LaTeX UTF-8.
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting thatlowercase
will reevaluate the catcode of¯
?
â Symbol 1
16 mins ago
The tilde is active. Thelowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.
â jfbu
13 mins ago
@jfbu Where can I find the exact behavior oflowercase
, including what you just said? Why on earth canlowercase
contains assignments... This blows my mind.
â Symbol 1
3 mins ago
TeX by Topic3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site foregreg+lowercase
for many many examples.
â jfbu
2 mins ago
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupdef~%
activatedefineï#1#2overline#1#2
begindocument
$ïab+ïbc=ïac$
enddocument
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefine|#1#2overline#1#2
begindocument
$|ab+|bc=|ac$
enddocument
I did not pay much attention to the actual macro, which is in math mode so math active would be possibly better.
Besides I don't want to have to handle UTF-8, so I used |
rather for the example.
AH! but OP is using XeTeX. So we can do this
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefineï#1#2overline#1#2
begindocument
thecatcode`ï % ONLY XETEX, NOT PDFTEX!
$ïab+ïbc=ïac$
enddocument
% Local variables:
% TeX-engine: xetex
% End:
Problem with pdflatex is that ï
is multibyte, and the erased code at top of my answer was redefinig the first byte, breaking LaTeX UTF-8.
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupdef~%
activatedefineï#1#2overline#1#2
begindocument
$ïab+ïbc=ïac$
enddocument
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefine|#1#2overline#1#2
begindocument
$|ab+|bc=|ac$
enddocument
I did not pay much attention to the actual macro, which is in math mode so math active would be possibly better.
Besides I don't want to have to handle UTF-8, so I used |
rather for the example.
AH! but OP is using XeTeX. So we can do this
documentclassarticle
defactivatedefine#1begingrouplccode`~=`#1relax
lowercaseendgroupcatcode`#1activedef~%
activatedefineï#1#2overline#1#2
begindocument
thecatcode`ï % ONLY XETEX, NOT PDFTEX!
$ïab+ïbc=ïac$
enddocument
% Local variables:
% TeX-engine: xetex
% End:
Problem with pdflatex is that ï
is multibyte, and the erased code at top of my answer was redefinig the first byte, breaking LaTeX UTF-8.
edited 17 mins ago
answered 34 mins ago
jfbu
41.8k61134
41.8k61134
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting thatlowercase
will reevaluate the catcode of¯
?
â Symbol 1
16 mins ago
The tilde is active. Thelowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.
â jfbu
13 mins ago
@jfbu Where can I find the exact behavior oflowercase
, including what you just said? Why on earth canlowercase
contains assignments... This blows my mind.
â Symbol 1
3 mins ago
TeX by Topic3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site foregreg+lowercase
for many many examples.
â jfbu
2 mins ago
add a comment |Â
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting thatlowercase
will reevaluate the catcode of¯
?
â Symbol 1
16 mins ago
The tilde is active. Thelowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.
â jfbu
13 mins ago
@jfbu Where can I find the exact behavior oflowercase
, including what you just said? Why on earth canlowercase
contains assignments... This blows my mind.
â Symbol 1
3 mins ago
TeX by Topic3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site foregreg+lowercase
for many many examples.
â jfbu
2 mins ago
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
Yes sorry don't take any notice of me
â David Carlisle
24 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting that
lowercase
will reevaluate the catcode of ¯
?â Symbol 1
16 mins ago
@jfbu Your trick works in XeLaTeX. Are you suggesting that
lowercase
will reevaluate the catcode of ¯
?â Symbol 1
16 mins ago
The tilde is active. The
lowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.â jfbu
13 mins ago
The tilde is active. The
lowercase
modifies the character code, but keeps the category code. So it creates an active token, which we can define. Then we must not forget to actually make this character associated to active category code.â jfbu
13 mins ago
@jfbu Where can I find the exact behavior of
lowercase
, including what you just said? Why on earth can lowercase
contains assignments... This blows my mind.â Symbol 1
3 mins ago
@jfbu Where can I find the exact behavior of
lowercase
, including what you just said? Why on earth can lowercase
contains assignments... This blows my mind.â Symbol 1
3 mins ago
TeX by Topic
3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site for egreg+lowercase
for many many examples.â jfbu
2 mins ago
TeX by Topic
3.6.4 Creative use of uppercase and lowercase
. A bit terse... but search this site for egreg+lowercase
for many many examples.â jfbu
2 mins ago
add a comment |Â
up vote
2
down vote
The simplest way is to use newunicodechar
; it just defines parameterless macros, but we can exploit the fact TeX is a macro expansion language to begin with.
Note that these examples can be used with all TeX engines (except Knuth TeX).
documentclassarticle
usepackagenewunicodechar
newunicodecharâ¾overline
newcommandtwooverline[2]overline#1#2
newunicodecharï¹Âtwooverline
begindocument
$â¾a$ $ï¹Âab$
enddocument
Another example:
documentclassarticle
usepackagenewunicodechar
makeatletter
newunicodecharâ¾symbol@overline
defsymbol@overline#1â¾overline#1 % must go second
begindocument
$â¾abcâ¾$
enddocument
add a comment |Â
up vote
2
down vote
The simplest way is to use newunicodechar
; it just defines parameterless macros, but we can exploit the fact TeX is a macro expansion language to begin with.
Note that these examples can be used with all TeX engines (except Knuth TeX).
documentclassarticle
usepackagenewunicodechar
newunicodecharâ¾overline
newcommandtwooverline[2]overline#1#2
newunicodecharï¹Âtwooverline
begindocument
$â¾a$ $ï¹Âab$
enddocument
Another example:
documentclassarticle
usepackagenewunicodechar
makeatletter
newunicodecharâ¾symbol@overline
defsymbol@overline#1â¾overline#1 % must go second
begindocument
$â¾abcâ¾$
enddocument
add a comment |Â
up vote
2
down vote
up vote
2
down vote
The simplest way is to use newunicodechar
; it just defines parameterless macros, but we can exploit the fact TeX is a macro expansion language to begin with.
Note that these examples can be used with all TeX engines (except Knuth TeX).
documentclassarticle
usepackagenewunicodechar
newunicodecharâ¾overline
newcommandtwooverline[2]overline#1#2
newunicodecharï¹Âtwooverline
begindocument
$â¾a$ $ï¹Âab$
enddocument
Another example:
documentclassarticle
usepackagenewunicodechar
makeatletter
newunicodecharâ¾symbol@overline
defsymbol@overline#1â¾overline#1 % must go second
begindocument
$â¾abcâ¾$
enddocument
The simplest way is to use newunicodechar
; it just defines parameterless macros, but we can exploit the fact TeX is a macro expansion language to begin with.
Note that these examples can be used with all TeX engines (except Knuth TeX).
documentclassarticle
usepackagenewunicodechar
newunicodecharâ¾overline
newcommandtwooverline[2]overline#1#2
newunicodecharï¹Âtwooverline
begindocument
$â¾a$ $ï¹Âab$
enddocument
Another example:
documentclassarticle
usepackagenewunicodechar
makeatletter
newunicodecharâ¾symbol@overline
defsymbol@overline#1â¾overline#1 % must go second
begindocument
$â¾abcâ¾$
enddocument
edited 2 mins ago
answered 14 mins ago
egreg
682k8318133061
682k8318133061
add a comment |Â
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%2f451042%2fchange-the-catcode-and-then-define-a-unicode-character%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
using
futurelet
will freeze the catcode of the next token (the one to which the macro is let). This may or not be relevant to your problems (I admit not having read in detail).â jfbu
37 mins ago
It's not a good idea to make the back quote active.
â egreg
30 mins ago
also what do you mean by Uniocde here? if you are using pdftex you can only define single byte tokens this way not arbitrary unicode characters.
â David Carlisle
27 mins ago
@jfbu That
futurelet
will freeze the catcode is unexpected (by me). That answers why TeX complains.â Symbol 1
25 mins ago
@egreg I did not want to make back quote active. If my code did that it is unintended. I (only) want to make non-ASCII characters active.
â Symbol 1
23 mins ago