# How do I have a second line in my header?

I would like to have a header that looks like

<my name>            <Class>             <page number>
<Student number>


However, I can't figure out how to insert the second line. What I've attempted is:

%Page layout here
\documentclass[letterpaper]{article}
\usepackage{lastpage}           %lets me find out how many pages there are

\usepackage{fancyhdr}           %allows me to fiddle with the header and such

\pagestyle{fancyplain}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\chead{How do I get this to work?}
%End footer

\begin{document}
Test
\end{document}


However, as you can see, this causes the essay name and page number to be on the same line as my student number, not up with my name as they should be.

-
Have you tried adding \\ to the end of \chead and \rhead? –  Silke Oct 6 '12 at 17:06

Use a tabular

%Page layout here
\documentclass[letterpaper]{article}
\usepackage{lastpage}           %lets me find out how many pages there are

\usepackage{fancyhdr}           %allows me to fiddle with the header and such

\pagestyle{fancyplain}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\chead{How do I get this to work?}
%End footer

\begin{document}
Test
\end{document}


A \parbox[t] would have worked the same, this spares us from guessing a length. This also spares us to add things to the other fields that don't belong there.

For the example I'll put back the rule, just to show the correctness of the spacing.

-
Your tabular has a bunch of @s and things that Alan's example doesn't, can you explain why? –  Canageek Oct 6 '12 at 17:13
@Canageek Try both. You'll see that @{} removes the small indentation. –  egreg Oct 6 '12 at 17:14
Now can you explain why using tabluar is more correct then just adding \\ at the end of each line? –  Canageek Oct 6 '12 at 17:20
@Canageek Because you don't have to guess; in this way you're just telling TeX what to do and don't add hacks. –  egreg Oct 6 '12 at 17:25