0

I am using one info.tex file that contains title, author names etc:

\author{my name}
\title{my title}
\date{\today}

I read this file in other files:

\documentclass{article}
\input{info}
\begin{document}
    \maketitle
\end{document}

Now I have another file which has same author names etc., but the title is slightly different: With the previous title, I have to add "part II" (as if, \title{my title part II}). Instead of rewriting the title again (as I have may files like this), I want to edit the title name from this document.

I tried

\makeatlettezr
\let\newtitle\@title
\makeatother
\renewcommand{\newtitle}{\@title part II}
\makeatletter
\renewcommand{\@title}{\newtitle}
\makeatother

but, as you expected, I got error. Can anyone help?

1
  • The problem with your code snippet is the use of \makeatlettezr, which doesn't exist, and the \makeatother ... \makeatletter following that. Just start out with \makeatletter and end with \makeatother. Also, use \@title{} part II to introduce a space after \@title.
    – Werner
    Commented Sep 23, 2018 at 18:02

1 Answer 1

2

You can redefine it using an \edef which expands the definition as much as possible. So you could do the following:

\makeatletter
\edef\@title{\@title\ part II}
\makeatother

If your \title does contain macros which shouldn't be expanded (yet) you can set things up so that \@title will be expanded only once with \unexpanded\expandafter:

\makeatletter
\edef\@title{\unexpanded\expandafter{\@title\ part II}}
\makeatother

In this case only the first token after the brace (so \@title in this case) will be expanded once.

2
  • This works... A small query: I want to put a new line (`\`) before "part II". This gives error. Can you help?
    – hola
    Commented Sep 24, 2018 at 6:59
  • 1
    @pushpen.paul did you try it with the second approach? The error is most likely because of the expansion of \\ . So you might want to try \edef\@title{\unexpanded\expandafter{\@title\\ part II}}
    – Skillmon
    Commented Sep 24, 2018 at 8:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .