I'm using the following to create this header:

enter image description here


\usepackage[left=0.5cm, right=1.1cm, top=-1cm, bottom=2cm]{geometry}
\usepackage{marvosym} % for icons
\usepackage{url} % for e-mail address
\usepackage{sectsty}  % for customizing section font


% Horizontal rule

    \textbf{\department}\hfill \textbf{\university}\newline
    \course\hfill \documentname\hfill \subject\newline


% Icons in letterhead
\newcommand{\emailicon}{\Email} % from marvosym



\setdepartment{TEXT 1}
\setuniversity{TEXT 2}
\setcourse{TEXT 3,TEXT 3, TEXT 3}
\setsubject{TEXT 4}
\setdocumentname{TEXT 5}
\setprofessor{TEXT 6}
\setoffice{TEXT 7}



However, text 5 is not centered when adding more text to text 3. I've tried to center text 5 but it creates much space between the rule.

What's the best way to center text 5 despite adding more text to text 3 or text 4?

  • You could put text3 and text4 into an makebox of zero width. So put \makebox[0pt][l]{\course}\hfill in the header...
    – Thruston
    May 18 '15 at 15:06

In order to center the document name, regardless of the size of the course name or the subject, you can replace this line

\course\hfill \documentname\hfill \subject\newline


\makebox[0pt][l]{\course}\hfill \documentname\hfill \makebox[0pt][r]{\subject}\newline

in your definition of \letterhead. This produces:

enter image description here

  • Note that I changed top=-1cm in the OP MWE to top=1cm in order to produce the answer above.
    – Thruston
    May 18 '15 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.