TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dozen or so course notes that I am writing. I have one 'styling file' (call it Master.tex) containing the header, and begin/end document - it specifies fonts, included packages, defined environments, etc. I then include the body of the document I want to compile. This way, all of my notes have the same styling, formatting, and feel.

However, the title of the document is declared in the header, which is in Master.tex. I would like to have a way to have this title be read off of the included body file - is this or something similar possible?

share|improve this question
Yes it is possible. However this all depends on how you specify the title and how you want to access it. So, really need you to compose a MWE that shows how the title is specified as a complete file, and how you want to use it. – Peter Grill Feb 24 '13 at 20:49
up vote 4 down vote accepted

Here's a solution using the fancyhdr package. (Edited to fix header formatting and to move \title to master file.)

% Master.tex

\newcommand{\thisdocument}{to be replaced}


\fancyhead{} % clear defaults


% included file contains the next lines
\renewcommand{\thisdocument}{What is the title of this lecture?}

Header on this page is what it should be.

Some lecture notes here ...
% end of included material

share|improve this answer
Thanks, this worked. I changed the pagestyle to plain, though, as fancy was printing the title three times at the top of every other page. – vgty6h7uij Feb 24 '13 at 21:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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