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.

Using LaTeX, I'm trying to make a multi-line header (using \markright), and having a somewhat difficult time doing it.

I've tried:

  1. Putting a table within the header using \markright{\begin{tabular}...\end{tabular}} This gives me an error: Paragraph ends before \reserved@a was complete.

  2. Simply inserting the newline with \\ This simplys crams everything on the same line, the exact same was as if there were no \\'s

Is there a "proper" way to do this in LaTeX using fancyhdr, or is there some sort of dark magic involved here?

share|improve this question
add comment

1 Answer 1

up vote 14 down vote accepted

Note that \markright has moving arguments, you should use:

\markright{\protect\parbox[b]{2cm}{foo\\bar}}

A \parbox or minipage is OK. But if you want to protect tabular, you can use:

\newcommand\headingtable{%
  \begin{tabular}[b]{l}foo\\bar\end{tabular}}
\markright{\protect\headingtable}

or (with fewer restrictions)

\newsavebox{\headingbox}
\sbox{\headingbox}{%
  \begin{minipage}[b]{5cm}
  foo\par bar
  \end{minipage}}
\markright{\usebox{\headingbox}}

Further reading:

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=protect

What is the difference between Fragile and Robust commands?

share|improve this answer
    
Good information - I saw something on tabular being fragile, but had no idea it applied here. Thanks for the quick response. –  new123456 Apr 23 '11 at 12:36
add comment

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.