How to fix this capitalization issue of a macro in the title-command?

Clash Royale CLAN TAG#URR8PPP
I wrote the following code to typeset the title page of a paper:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
begindocument
title[Title Title Title]Title Title Title
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
This outputs the following:

However, I wanted to make my title a macro, because I need it elsewhere too:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
But this now outputs the following:

No way of fiddling got me the capitalization back. E.g. there is no difference in using def. What is happening here and how to fix it?
macros formatting titles capitalization
add a comment |
I wrote the following code to typeset the title page of a paper:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
begindocument
title[Title Title Title]Title Title Title
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
This outputs the following:

However, I wanted to make my title a macro, because I need it elsewhere too:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
But this now outputs the following:

No way of fiddling got me the capitalization back. E.g. there is no difference in using def. What is happening here and how to fix it?
macros formatting titles capitalization
expandaftertitleexpandaftermytitleshould work.
– Ulrike Fischer
Jan 2 at 14:17
@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
Jan 2 at 14:23
add a comment |
I wrote the following code to typeset the title page of a paper:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
begindocument
title[Title Title Title]Title Title Title
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
This outputs the following:

However, I wanted to make my title a macro, because I need it elsewhere too:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
But this now outputs the following:

No way of fiddling got me the capitalization back. E.g. there is no difference in using def. What is happening here and how to fix it?
macros formatting titles capitalization
I wrote the following code to typeset the title page of a paper:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
begindocument
title[Title Title Title]Title Title Title
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
This outputs the following:

However, I wanted to make my title a macro, because I need it elsewhere too:
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument
But this now outputs the following:

No way of fiddling got me the capitalization back. E.g. there is no difference in using def. What is happening here and how to fix it?
macros formatting titles capitalization
macros formatting titles capitalization
asked Jan 2 at 14:08
M. WinterM. Winter
290110
290110
expandaftertitleexpandaftermytitleshould work.
– Ulrike Fischer
Jan 2 at 14:17
@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
Jan 2 at 14:23
add a comment |
expandaftertitleexpandaftermytitleshould work.
– Ulrike Fischer
Jan 2 at 14:17
@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
Jan 2 at 14:23
expandaftertitleexpandaftermytitle should work.– Ulrike Fischer
Jan 2 at 14:17
expandaftertitleexpandaftermytitle should work.– Ulrike Fischer
Jan 2 at 14:17
@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
Jan 2 at 14:23
@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
Jan 2 at 14:23
add a comment |
2 Answers
2
active
oldest
votes
Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
usepackagetextcase
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument

Let's see the definition of title
renewcommand*title[2]gdefshorttitle#1gdef@title#2
edeftitle@nx@dblarg
@xp@nxcsnamestringtitleendcsname
This is a common trick in the class for telling LaTeX that if the optional argument is missing then the mandatory argument should be supplied instead.
The problem arises when maketitle is processed, which does @settitle:
def@settitlebegincenter%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
endcenter%
OK, we should look at uppercasenonmath:
newcommanduppercasenonmath[1]toks@@emptytoks
@xp@skipmath@xp@empty#1$$%
edef#1@nxprotect@nx@upprepthetoks@%
This only expands @title once, so at the end the primitive uppercase is applied to mytitle (it would be a bit long to go into the details). However the class also has
AtBeginDocument%
@ifundefinedMakeTextUppercaseletuppercasenonmathaltucnm%
and we find
defaltucnm#1%
MakeTextUppercasetoks@#1%
edef#1thetoks@%
and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
@M.Winter Added some details
– egreg
Jan 2 at 14:40
add a comment |
Too long for a comment
expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandaftermytitle
But @egreg answer is worthwile reading too. :)
Wow, this is insanity. I mean I triedexpandafter, but I was not aware that just using more might fix the problem :D
– M. Winter
Jan 2 at 14:57
eh eh... you usually need them by groups of2^n -1heren=2because we need to expand once two things.
– jfbu
Jan 2 at 14:58
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]
– Ulrich Diez
Jan 2 at 19:02
@UlrichDiez yes, and withunexpandedexpandafterfoomethods it is even easier to control expansion in arbitrary locations in anedef,begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex
– jfbu
Jan 2 at 22:14
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468245%2fhow-to-fix-this-capitalization-issue-of-a-macro-in-the-title-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
usepackagetextcase
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument

Let's see the definition of title
renewcommand*title[2]gdefshorttitle#1gdef@title#2
edeftitle@nx@dblarg
@xp@nxcsnamestringtitleendcsname
This is a common trick in the class for telling LaTeX that if the optional argument is missing then the mandatory argument should be supplied instead.
The problem arises when maketitle is processed, which does @settitle:
def@settitlebegincenter%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
endcenter%
OK, we should look at uppercasenonmath:
newcommanduppercasenonmath[1]toks@@emptytoks
@xp@skipmath@xp@empty#1$$%
edef#1@nxprotect@nx@upprepthetoks@%
This only expands @title once, so at the end the primitive uppercase is applied to mytitle (it would be a bit long to go into the details). However the class also has
AtBeginDocument%
@ifundefinedMakeTextUppercaseletuppercasenonmathaltucnm%
and we find
defaltucnm#1%
MakeTextUppercasetoks@#1%
edef#1thetoks@%
and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
@M.Winter Added some details
– egreg
Jan 2 at 14:40
add a comment |
Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
usepackagetextcase
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument

Let's see the definition of title
renewcommand*title[2]gdefshorttitle#1gdef@title#2
edeftitle@nx@dblarg
@xp@nxcsnamestringtitleendcsname
This is a common trick in the class for telling LaTeX that if the optional argument is missing then the mandatory argument should be supplied instead.
The problem arises when maketitle is processed, which does @settitle:
def@settitlebegincenter%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
endcenter%
OK, we should look at uppercasenonmath:
newcommanduppercasenonmath[1]toks@@emptytoks
@xp@skipmath@xp@empty#1$$%
edef#1@nxprotect@nx@upprepthetoks@%
This only expands @title once, so at the end the primitive uppercase is applied to mytitle (it would be a bit long to go into the details). However the class also has
AtBeginDocument%
@ifundefinedMakeTextUppercaseletuppercasenonmathaltucnm%
and we find
defaltucnm#1%
MakeTextUppercasetoks@#1%
edef#1thetoks@%
and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
@M.Winter Added some details
– egreg
Jan 2 at 14:40
add a comment |
Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
usepackagetextcase
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument

Let's see the definition of title
renewcommand*title[2]gdefshorttitle#1gdef@title#2
edeftitle@nx@dblarg
@xp@nxcsnamestringtitleendcsname
This is a common trick in the class for telling LaTeX that if the optional argument is missing then the mandatory argument should be supplied instead.
The problem arises when maketitle is processed, which does @settitle:
def@settitlebegincenter%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
endcenter%
OK, we should look at uppercasenonmath:
newcommanduppercasenonmath[1]toks@@emptytoks
@xp@skipmath@xp@empty#1$$%
edef#1@nxprotect@nx@upprepthetoks@%
This only expands @title once, so at the end the primitive uppercase is applied to mytitle (it would be a bit long to go into the details). However the class also has
AtBeginDocument%
@ifundefinedMakeTextUppercaseletuppercasenonmathaltucnm%
and we find
defaltucnm#1%
MakeTextUppercasetoks@#1%
edef#1thetoks@%
and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.
Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.
documentclassamsart
usepackage[T1]fontenc
usepackage[utf8]inputenc
usepackage[USenglish]babel
usepackagetextcase
newcommandmytitleTitle title title
begindocument
title[mytitle]mytitle
beginabstract
Abstract abstract abstract
endabstract
maketitle
enddocument

Let's see the definition of title
renewcommand*title[2]gdefshorttitle#1gdef@title#2
edeftitle@nx@dblarg
@xp@nxcsnamestringtitleendcsname
This is a common trick in the class for telling LaTeX that if the optional argument is missing then the mandatory argument should be supplied instead.
The problem arises when maketitle is processed, which does @settitle:
def@settitlebegincenter%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
endcenter%
OK, we should look at uppercasenonmath:
newcommanduppercasenonmath[1]toks@@emptytoks
@xp@skipmath@xp@empty#1$$%
edef#1@nxprotect@nx@upprepthetoks@%
This only expands @title once, so at the end the primitive uppercase is applied to mytitle (it would be a bit long to go into the details). However the class also has
AtBeginDocument%
@ifundefinedMakeTextUppercaseletuppercasenonmathaltucnm%
and we find
defaltucnm#1%
MakeTextUppercasetoks@#1%
edef#1thetoks@%
and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.
edited Jan 2 at 14:40
answered Jan 2 at 14:21
egregegreg
712k8618933179
712k8618933179
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
@M.Winter Added some details
– egreg
Jan 2 at 14:40
add a comment |
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
@M.Winter Added some details
– egreg
Jan 2 at 14:40
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
Thank you, this solved the problem. Can you tell a little bit about why this problem happened in the first place and how textcase fixed it?
– M. Winter
Jan 2 at 14:24
@M.Winter Added some details
– egreg
Jan 2 at 14:40
@M.Winter Added some details
– egreg
Jan 2 at 14:40
add a comment |
Too long for a comment
expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandaftermytitle
But @egreg answer is worthwile reading too. :)
Wow, this is insanity. I mean I triedexpandafter, but I was not aware that just using more might fix the problem :D
– M. Winter
Jan 2 at 14:57
eh eh... you usually need them by groups of2^n -1heren=2because we need to expand once two things.
– jfbu
Jan 2 at 14:58
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]
– Ulrich Diez
Jan 2 at 19:02
@UlrichDiez yes, and withunexpandedexpandafterfoomethods it is even easier to control expansion in arbitrary locations in anedef,begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex
– jfbu
Jan 2 at 22:14
add a comment |
Too long for a comment
expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandaftermytitle
But @egreg answer is worthwile reading too. :)
Wow, this is insanity. I mean I triedexpandafter, but I was not aware that just using more might fix the problem :D
– M. Winter
Jan 2 at 14:57
eh eh... you usually need them by groups of2^n -1heren=2because we need to expand once two things.
– jfbu
Jan 2 at 14:58
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]
– Ulrich Diez
Jan 2 at 19:02
@UlrichDiez yes, and withunexpandedexpandafterfoomethods it is even easier to control expansion in arbitrary locations in anedef,begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex
– jfbu
Jan 2 at 22:14
add a comment |
Too long for a comment
expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandaftermytitle
But @egreg answer is worthwile reading too. :)
Too long for a comment
expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandaftermytitle
But @egreg answer is worthwile reading too. :)
answered Jan 2 at 14:55
jfbujfbu
46.5k66148
46.5k66148
Wow, this is insanity. I mean I triedexpandafter, but I was not aware that just using more might fix the problem :D
– M. Winter
Jan 2 at 14:57
eh eh... you usually need them by groups of2^n -1heren=2because we need to expand once two things.
– jfbu
Jan 2 at 14:58
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]
– Ulrich Diez
Jan 2 at 19:02
@UlrichDiez yes, and withunexpandedexpandafterfoomethods it is even easier to control expansion in arbitrary locations in anedef,begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex
– jfbu
Jan 2 at 22:14
add a comment |
Wow, this is insanity. I mean I triedexpandafter, but I was not aware that just using more might fix the problem :D
– M. Winter
Jan 2 at 14:57
eh eh... you usually need them by groups of2^n -1heren=2because we need to expand once two things.
– jfbu
Jan 2 at 14:58
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]
– Ulrich Diez
Jan 2 at 19:02
@UlrichDiez yes, and withunexpandedexpandafterfoomethods it is even easier to control expansion in arbitrary locations in anedef,begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex
– jfbu
Jan 2 at 22:14
Wow, this is insanity. I mean I tried
expandafter, but I was not aware that just using more might fix the problem :D– M. Winter
Jan 2 at 14:57
Wow, this is insanity. I mean I tried
expandafter, but I was not aware that just using more might fix the problem :D– M. Winter
Jan 2 at 14:57
eh eh... you usually need them by groups of
2^n -1 here n=2 because we need to expand once two things.– jfbu
Jan 2 at 14:58
eh eh... you usually need them by groups of
2^n -1 here n=2 because we need to expand once two things.– jfbu
Jan 2 at 14:58
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]– Ulrich Diez
Jan 2 at 19:02
newcommandPassFirstToSecond[2]#2#1 ... expandafterPassFirstToSecondexpandaftermytitleexpandaftertitleexpandafter[mytitle]– Ulrich Diez
Jan 2 at 19:02
@UlrichDiez yes, and with
unexpandedexpandafterfoo methods it is even easier to control expansion in arbitrary locations in an edef, begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex– jfbu
Jan 2 at 22:14
@UlrichDiez yes, and with
unexpandedexpandafterfoo methods it is even easier to control expansion in arbitrary locations in an edef, begingroupedefxendgroupnoexpandtitle[unexpandedexpandaftermytitle]unexpandedexpandaftermytitlex– jfbu
Jan 2 at 22:14
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468245%2fhow-to-fix-this-capitalization-issue-of-a-macro-in-the-title-command%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
expandaftertitleexpandaftermytitleshould work.– Ulrike Fischer
Jan 2 at 14:17
@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
Jan 2 at 14:23