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












2














I wrote the following code to typeset the title page of a paper:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

begin{document}

title[Title Title Title]{Title Title Title}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


This outputs the following:



enter image description here



However, I wanted to make my title a macro, because I need it elsewhere too:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


But this now outputs the following:



enter image description here



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?










share|improve this question






















  • expandaftertitleexpandafter{mytitle} should work.
    – Ulrike Fischer
    1 hour ago










  • @UlrikeFischer I tried this, and unformtunately it does not work.
    – M. Winter
    54 mins ago
















2














I wrote the following code to typeset the title page of a paper:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

begin{document}

title[Title Title Title]{Title Title Title}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


This outputs the following:



enter image description here



However, I wanted to make my title a macro, because I need it elsewhere too:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


But this now outputs the following:



enter image description here



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?










share|improve this question






















  • expandaftertitleexpandafter{mytitle} should work.
    – Ulrike Fischer
    1 hour ago










  • @UlrikeFischer I tried this, and unformtunately it does not work.
    – M. Winter
    54 mins ago














2












2








2







I wrote the following code to typeset the title page of a paper:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

begin{document}

title[Title Title Title]{Title Title Title}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


This outputs the following:



enter image description here



However, I wanted to make my title a macro, because I need it elsewhere too:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


But this now outputs the following:



enter image description here



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?










share|improve this question













I wrote the following code to typeset the title page of a paper:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

begin{document}

title[Title Title Title]{Title Title Title}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


This outputs the following:



enter image description here



However, I wanted to make my title a macro, because I need it elsewhere too:



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


But this now outputs the following:



enter image description here



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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 1 hour ago









M. Winter

28519




28519












  • expandaftertitleexpandafter{mytitle} should work.
    – Ulrike Fischer
    1 hour ago










  • @UlrikeFischer I tried this, and unformtunately it does not work.
    – M. Winter
    54 mins ago


















  • expandaftertitleexpandafter{mytitle} should work.
    – Ulrike Fischer
    1 hour ago










  • @UlrikeFischer I tried this, and unformtunately it does not work.
    – M. Winter
    54 mins ago
















expandaftertitleexpandafter{mytitle} should work.
– Ulrike Fischer
1 hour ago




expandaftertitleexpandafter{mytitle} should work.
– Ulrike Fischer
1 hour ago












@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
54 mins ago




@UlrikeFischer I tried this, and unformtunately it does not work.
– M. Winter
54 mins ago










2 Answers
2






active

oldest

votes


















3














Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}
usepackage{textcase}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


enter image description here



Let's see the definition of title



renewcommand*{title}[2]{gdefshorttitle{#1}gdef@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@settitle{begin{center}%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
end{center}%
}


OK, we should look at uppercasenonmath:



newcommand{uppercasenonmath}[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{%
@ifundefined{MakeTextUppercase}{}{letuppercasenonmathaltucnm}%
}


and we find



defaltucnm#1{%
MakeTextUppercase{toks@{#1}}%
edef#1{thetoks@}%
}


and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.






share|improve this answer























  • 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
    53 mins ago










  • @M.Winter Added some details
    – egreg
    37 mins ago



















1














Too long for a comment



expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandafter{mytitle}


But @egreg answer is worthwile reading too. :)






share|improve this answer





















  • 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
    21 mins ago










  • eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
    – jfbu
    19 mins ago











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
});


}
});














draft saved

draft discarded


















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









3














Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}
usepackage{textcase}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


enter image description here



Let's see the definition of title



renewcommand*{title}[2]{gdefshorttitle{#1}gdef@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@settitle{begin{center}%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
end{center}%
}


OK, we should look at uppercasenonmath:



newcommand{uppercasenonmath}[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{%
@ifundefined{MakeTextUppercase}{}{letuppercasenonmathaltucnm}%
}


and we find



defaltucnm#1{%
MakeTextUppercase{toks@{#1}}%
edef#1{thetoks@}%
}


and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.






share|improve this answer























  • 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
    53 mins ago










  • @M.Winter Added some details
    – egreg
    37 mins ago
















3














Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}
usepackage{textcase}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


enter image description here



Let's see the definition of title



renewcommand*{title}[2]{gdefshorttitle{#1}gdef@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@settitle{begin{center}%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
end{center}%
}


OK, we should look at uppercasenonmath:



newcommand{uppercasenonmath}[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{%
@ifundefined{MakeTextUppercase}{}{letuppercasenonmathaltucnm}%
}


and we find



defaltucnm#1{%
MakeTextUppercase{toks@{#1}}%
edef#1{thetoks@}%
}


and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.






share|improve this answer























  • 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
    53 mins ago










  • @M.Winter Added some details
    – egreg
    37 mins ago














3












3








3






Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}
usepackage{textcase}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


enter image description here



Let's see the definition of title



renewcommand*{title}[2]{gdefshorttitle{#1}gdef@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@settitle{begin{center}%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
end{center}%
}


OK, we should look at uppercasenonmath:



newcommand{uppercasenonmath}[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{%
@ifundefined{MakeTextUppercase}{}{letuppercasenonmathaltucnm}%
}


and we find



defaltucnm#1{%
MakeTextUppercase{toks@{#1}}%
edef#1{thetoks@}%
}


and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.






share|improve this answer














Unfortunately, amsart uses by default uppercase (a big nuisance). Happily, the fix is simple: load textcase.



documentclass{amsart}

usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage[USenglish]{babel}
usepackage{textcase}

newcommandmytitle{Title title title}

begin{document}

title[mytitle]{mytitle}

begin{abstract}
Abstract abstract abstract
end{abstract}

maketitle

end{document}


enter image description here



Let's see the definition of title



renewcommand*{title}[2]{gdefshorttitle{#1}gdef@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@settitle{begin{center}%
baselineskip14p@relax
bfseries
uppercasenonmath@title
@title
end{center}%
}


OK, we should look at uppercasenonmath:



newcommand{uppercasenonmath}[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{%
@ifundefined{MakeTextUppercase}{}{letuppercasenonmathaltucnm}%
}


and we find



defaltucnm#1{%
MakeTextUppercase{toks@{#1}}%
edef#1{thetoks@}%
}


and this is much better, because MakeTextUppercase does full (protected) expansion of its argument, so your mytitle gets expanded before uppercasing is done.







share|improve this answer














share|improve this answer



share|improve this answer








edited 37 mins ago

























answered 56 mins ago









egreg

709k8618833166




709k8618833166












  • 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
    53 mins ago










  • @M.Winter Added some details
    – egreg
    37 mins ago


















  • 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
    53 mins ago










  • @M.Winter Added some details
    – egreg
    37 mins ago
















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
53 mins ago




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
53 mins ago












@M.Winter Added some details
– egreg
37 mins ago




@M.Winter Added some details
– egreg
37 mins ago











1














Too long for a comment



expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandafter{mytitle}


But @egreg answer is worthwile reading too. :)






share|improve this answer





















  • 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
    21 mins ago










  • eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
    – jfbu
    19 mins ago
















1














Too long for a comment



expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandafter{mytitle}


But @egreg answer is worthwile reading too. :)






share|improve this answer





















  • 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
    21 mins ago










  • eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
    – jfbu
    19 mins ago














1












1








1






Too long for a comment



expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandafter{mytitle}


But @egreg answer is worthwile reading too. :)






share|improve this answer












Too long for a comment



expandafterexpandafterexpandaftertitleexpandafterexpandafterexpandafter[expandaftermytitleexpandafter]expandafter{mytitle}


But @egreg answer is worthwile reading too. :)







share|improve this answer












share|improve this answer



share|improve this answer










answered 22 mins ago









jfbu

46.1k66148




46.1k66148












  • 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
    21 mins ago










  • eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
    – jfbu
    19 mins ago


















  • 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
    21 mins ago










  • eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
    – jfbu
    19 mins ago
















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
21 mins ago




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
21 mins ago












eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
– jfbu
19 mins ago




eh eh... you usually need them by groups of 2^n -1 here n=2 because we need to expand once two things.
– jfbu
19 mins ago


















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


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




draft saved


draft discarded














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





















































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







Popular posts from this blog

Eastern Orthodox Church

Zagreb

Understanding the information contained in the Deep Space Network XML data?