4

I made my own preamble and saved it into a separate file. I include it with

\input{Preamble}

Now in the preamble there is

\title{MyTitle}

Now I want to pass MyTitle from my main document. How do I do that?

  • 1
    why don't you take that line out of Preamble.tex and put it in the main document? (which is more useful, if you want to share the preamble code – David Carlisle Feb 1 '16 at 7:59
  • you can type \title{NewTitle} after \input{Preamble} – touhami Feb 1 '16 at 8:05
  • you could change the preamble to \title{\realtitle} and then you would have to say something like \newcommand{\realtitle}{My Title} beforehand – Bort Feb 1 '16 at 8:35
  • \title is already storing it's argument to \@title. Using another \realtitle would introduce a third layer of macros ;-) – user31729 Feb 1 '16 at 11:21
  • @DavidCarlisle This is the way I did it now. Thanks for the idea. – Michael S. Feb 1 '16 at 12:52
3

You could take that line out of Preamble.tex and put it in the main document. Which is more useful, if you want to share the preamble code with other documents.

Incidentally it would be more idiomatic latex if you called your file preamble.sty rather than Preamble.tex then you could use

\documentclass{article}
\usepackage{preamble}
\title{my title}
\begin{document}
\maketitle
\end{document}
| improve this answer | |

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.