1

I'm using the following to create this header:

enter image description here

\documentclass[12pt]{article}

\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

\sectionfont{\normalsize\bfseries}

% Horizontal rule
\newlength{\normalrulethickness}
\setlength{\normalrulethickness}{0.4pt}
\newcommand{\thinrule}{\noindent\rule{\linewidth}{\normalrulethickness}}
\newcommand{\thickrule}{\noindent\rule{\linewidth}{2\normalrulethickness}}
\newcommand{\doublerule}{%
    \thickrule%
    \llap{\rule[2pt]{\linewidth}{\normalrulethickness}}%
}

\newcommand{\letterhead}{%
    \noindent%
    \textbf{\department}\hfill \textbf{\university}\newline
    \course\hfill \documentname\hfill \subject\newline
    \doublerule\par\smallskip
    {\small\noindent%
    \professor\hfill 
        %\emailicon\ 
        %\email\hfill 
        %\phoneicon\
        %\phone\hfill
        \office%
    }\par\bigskip%
}

\newcommand{\setdepartment}[1]{\gdef\department{#1}}
\newcommand{\setuniversity}[1]{\gdef\university{#1}}
\newcommand{\setcourse}[1]{\gdef\course{#1}}
\newcommand{\setsubject}[1]{\gdef\subject{#1}}
\newcommand{\setdocumentname}[1]{\gdef\documentname{#1}}
\newcommand{\setprofessor}[1]{\gdef\professor{#1}}
\newcommand{\setemail}[1]{\gdef\email{\url{#1}}}
\newcommand{\setphone}[1]{\gdef\phone{#1}}
\newcommand{\setoffice}[1]{\gdef\office{#1}}

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

\newcommand{\pointvalue}[1]{\hfill\mbox{#1}}
\newcommand{\strong}[1]{\textbf{#1}}

\begin{document}

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

\letterhead

\end{document}

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
3

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

with

\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.