Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
1  
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

1 Answer 1

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
%
\documentclass{article}

\newcommand{\thisdocument}{to be replaced}

\title{\thisdocument}

\usepackage{fancyhdr}
\pagestyle{fancy} 
\fancyhead{} % clear defaults
\fancyhead[C]{\thisdocument}

\begin{document}

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

\maketitle
\newpage
Header on this page is what it should be.

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

\end{document}
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

 
discard

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.