Text FormattingTwo line header, one line spanning columns

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Two line header, one line spanning columns

Post by Singularity »

I would like to create a two line header on each page, but one of the lines should be centered and span columns. Something like this
Name: _______________ Date: ____
Test 1: Ch 1.6 thorugh 3.4
Or I might want the "Test.." line on top and then the name (but that's minor).

I've tried various solutions, including this

Code: Select all

\documentclass[addpoints]{exam}

\pagestyle{headandfoot}
\lhead{\makebox[.5\textwidth][l]{Name:\enspace\hrulefill}}
\chead{\hspace{1ex} \\ Test 1: Ch 1.5 thorugh 3.4}
\rhead{\makebox[.25\textwidth]{Date:\enspace\hrulefill}}

\footrule
\lfoot{Test 1: Ch 1.5 through 3.4}
\cfoot{}
\rfoot{Page \thepage\ of \numpages}

\begin{document}
question 1 \\ question 1 \\ question 3 \\ etc.\vdots
\end{document}
But the title line is overwriting the blank space for name.

Adding "\extraheadheight" didn't make a difference, and I could not find antying in the fancyhdr package to help. Did I stump LaTeX?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Two line header, one line spanning columns

Post by Johannes_B »

Something like this?

Code: Select all

\documentclass[addpoints]{exam}

\newcommand{\examNo}{Test 1: Ch 1.5 thorugh 3.4}

\extraheadheight{\baselineskip}
\pagestyle{headandfoot}
\firstpageheader{%
\makebox[.5\textwidth][l]{Name:\enspace\hrulefill}\\}{%
~\\ \examNo}{%
\makebox[.25\textwidth]{Date:\enspace\hrulefill}\\%
}
\firstpageheadrule

\footrule
\lfoot{\examNo}
\cfoot{}
\rfoot{Page \thepage\ of \numpages}

\begin{document}
\begin{questions}
\question A question 
\question Another question
\end{questions}
\end{document}

Best regards
Johanns
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply