LaTeX forum ⇒ Text FormattingTwo line header, one line spanning columns Topic is solved

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

Two line header, one line spanning columns

Postby Singularity » Mon Sep 23, 2013 10:41 am

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
  1. \documentclass[addpoints]{exam}
  2.  
  3. \pagestyle{headandfoot}
  4. \lhead{\makebox[.5\textwidth][l]{Name:\enspace\hrulefill}}
  5. \chead{\hspace{1ex} \\ Test 1: Ch 1.5 thorugh 3.4}
  6. \rhead{\makebox[.25\textwidth]{Date:\enspace\hrulefill}}
  7.  
  8. \footrule
  9. \lfoot{Test 1: Ch 1.5 through 3.4}
  10. \cfoot{}
  11. \rfoot{Page \thepage\ of \numpages}
  12.  
  13. \begin{document}
  14. question 1 \\ question 1 \\ question 3 \\ etc.\vdots
  15. \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?

Tags:

User avatar
Johannes_B
Site Moderator
Posts: 4044
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Mon Sep 23, 2013 11:22 am

Something like this?

  1. \documentclass[addpoints]{exam}
  2.  
  3. \newcommand{\examNo}{Test 1: Ch 1.5 thorugh 3.4}
  4.  
  5. \extraheadheight{\baselineskip}
  6. \pagestyle{headandfoot}
  7. \firstpageheader{%
  8. \makebox[.5\textwidth][l]{Name:\enspace\hrulefill}\\}{%
  9. ~\\ \examNo}{%
  10. \makebox[.25\textwidth]{Date:\enspace\hrulefill}\\%
  11. }
  12. \firstpageheadrule
  13.  
  14. \footrule
  15. \lfoot{\examNo}
  16. \cfoot{}
  17. \rfoot{Page \thepage\ of \numpages}
  18.  
  19. \begin{document}
  20. \begin{questions}
  21. \question A question
  22. \question Another question
  23. \end{questions}
  24. \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.


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 5 guests