Change the catcode and then define a (Unicode) character

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question























  • 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














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









share|improve this question























  • 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












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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 15 mins ago

























asked 41 mins ago









Symbol 1

24k235111




24k235111











  • 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
















  • 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















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










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


enter image description here



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:


enter image description here



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.






share|improve this answer






















  • 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











  • 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










  • 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


















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


enter image description here



Another example:



documentclassarticle

usepackagenewunicodechar

makeatletter
newunicodechar‾symbol@overline
defsymbol@overline#1‾overline#1 % must go second

begindocument

$‾abc‾$

enddocument


enter image description here






share|improve this answer






















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "85"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    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






























    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


    enter image description here



    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:


    enter image description here



    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.






    share|improve this answer






















    • 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











    • 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










    • 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















    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


    enter image description here



    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:


    enter image description here



    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.






    share|improve this answer






















    • 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











    • 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










    • 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













    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


    enter image description here



    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:


    enter image description here



    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.






    share|improve this answer
















    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


    enter image description here



    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:


    enter image description here



    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.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    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 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










    • @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

















    • 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











    • 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










    • 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
















    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











    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


    enter image description here



    Another example:



    documentclassarticle

    usepackagenewunicodechar

    makeatletter
    newunicodechar‾symbol@overline
    defsymbol@overline#1‾overline#1 % must go second

    begindocument

    $‾abc‾$

    enddocument


    enter image description here






    share|improve this answer


























      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


      enter image description here



      Another example:



      documentclassarticle

      usepackagenewunicodechar

      makeatletter
      newunicodechar‾symbol@overline
      defsymbol@overline#1‾overline#1 % must go second

      begindocument

      $‾abc‾$

      enddocument


      enter image description here






      share|improve this answer
























        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


        enter image description here



        Another example:



        documentclassarticle

        usepackagenewunicodechar

        makeatletter
        newunicodechar‾symbol@overline
        defsymbol@overline#1‾overline#1 % must go second

        begindocument

        $‾abc‾$

        enddocument


        enter image description here






        share|improve this answer














        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


        enter image description here



        Another example:



        documentclassarticle

        usepackagenewunicodechar

        makeatletter
        newunicodechar‾symbol@overline
        defsymbol@overline#1‾overline#1 % must go second

        begindocument

        $‾abc‾$

        enddocument


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 2 mins ago

























        answered 14 mins ago









        egreg

        682k8318133061




        682k8318133061



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            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













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery