1

I want to know how to format text to act as a title as is shown in the image below. They have a line, text and then another line below. I am only beginning to use TeX so the only way I can think of doing this is by creating a tabular environment and using \hline , but I am not sure how to make this span the text width.

enter image description here

2
  • Welcome to TeX.SE.
    – Mico
    Jul 27, 2021 at 2:21
  • Is this on every page or just the title page? BTW there is also \hrule and \rule. Jul 27, 2021 at 15:29

2 Answers 2

0

Here is a tabular* based version:

enter image description here

\documentclass{article}

\usepackage{booktabs}
\usepackage{fancyhdr}

\renewcommand{\headrulewidth}{0pt}
\setlength{\headheight}{48.2pt}
\pagestyle{fancy}
\fancyhf{}

\fancyhead[C]{
\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}cr}
\multicolumn{3}{c}{\scshape Department of Mathematics}\\ [5pt]
\toprule
\scshape MATHS 254S2 & Tutorial 1 (Week 2) & July 26/30, 2021 \\
\bottomrule
\end{tabular*}
}

\usepackage{lipsum} % For dummy text. Do not use in actual document.

\begin{document}
\lipsum
\end{document}
1

A possible way is as follows combining the fancyhdr package and the \rule command.

\documentclass{article}
\usepackage{lipsum}%to involke text examples
%%%to set page head and foot%%%%%%%%%%%%%%%%%%%%
\usepackage{fancyhdr}%调用宏包
%set new plain style----------------------------
\fancypagestyle{plain}{
 \fancyhf{}
 \fancyhead{}
 \fancyfoot{}
\renewcommand{\headrulewidth}{0pt}}
\renewcommand{\headrulewidth}{0pt}

\title{A Test}
\begin{document}
\maketitle
\pagestyle{fancy}
\fancyhf{}
\fancyhead[C]{
{\small\scshape Department of Mathematics}
\\[-.2em]\rule{\textwidth}{0.4pt}
\\[-.2em]{\small MATHS 254S2\hfill Tutorial 1 (Week 2)\hfill July 26/30, 2021}
\\[-.7em]\rule{\textwidth}{0.4pt}
}
\fancyfoot[C]{\small\thepage}

\lipsum[1-10]

\end{document}

The output is as follows:

enter image description here

1
  • Thank you so much!
    – raynerk
    Jul 27, 2021 at 7:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .