8

I was trying to write a custom LaTeX class where I need to access the value of \@title. I wrote

\newcommand{\makeack}{Hello World  \@title World}

But the value of \@title is not printed when I use \makeack in the .tex file. But I could successfully use \@title in the modified \@maketitle I defined like

\def\@maketitle{% 
....
....
}

I am a beginner in writing classes.

7

The default document classes make the title-related macros (\@title, \@date and \@author) empty once you call \maketitle. If you wish to keep copies of them around, you need to store these elsewhere. One way would be to update the \title (and friends) macro to not only store its contents in \@title (yes, that's what \title does), but also in something for your use, like \stored@title, say:

\def\title#1{\gdef\@title{#1}\gdef\stored@title{#1}}
\def\author#1{\gdef\@author{#1}\gdef\stored@author{#1}}
\def\date#1{\gdef\@date{#1}\gdef\stored@date{#1}}

The titling package does a similar thing, if you're interested.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.