4

Here's a small document that uses the fancyhdr package to customize the header. The output is very nice, for what I need to do. However, I need the header to appears on all pages except the first page (which has a title). How can I do that in a minimal way, from the code below?

Take note that I need to keep the footer with its page number on all pages, even on the first page.

\documentclass[12pt,letterpaper,twoside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{microtype}
\usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{sectsty}
\allsectionsfont{\centering\normalfont\scshape}
\usepackage{lipsum}

\usepackage[page]{totalcount}
\usepackage{fancyhdr} %
\pagestyle{fancyplain}
\fancyhead[L]{} %
\fancyhead[C]{\textsc{Some title in the header}}
\fancyhead[R]{} %
\fancyfoot[L]{}
\fancyfoot[C]{}
\fancyfoot[LE]{Page \thepage~of \totalpages}
\fancyfoot[RO]{Page \thepage~of \totalpages}

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}}

\title{\normalfont\normalsize
    \horrule{0.5pt} \\[0.4cm]
    \huge \textsc{Testament} \\
    \horrule{2pt} \\[0.5cm]
}

\author{John Doe}
\date{\normalsize\today}

\begin{document}

\maketitle

\section{Some funny title}

\lipsum[2-12]

\end{document}

Preview, with the offending header shown in red:

enter image description here

2 Answers 2

8

You need to add \thispagestyle{empty} after \maketitle.

Edit: According to your comment, you need to (re)define page style \plain (so far you not define it as fancyhdr style) and define new page style, let be named firstpage. Changed code are indicated by comments in MWE:

\documentclass[12pt,letterpaper,twoside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{microtype}
\usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{sectsty}
\allsectionsfont{\centering\normalfont\scshape}
\usepackage{lipsum}

\usepackage[page]{totalcount}
\usepackage{fancyhdr} %
%---------------------------------------------------------------%
% new definition of the fancy headers and footers
%---------------------------------------------------------------%
\fancypagestyle{plain}% <--- new
{%
\fancyhf{}%             <--- new
\fancyhead[C]{\textsc{Some title in the header}}%
\fancyfoot[LE]{Page \thepage~of \totalpages}%
\fancyfoot[RO]{Page \thepage~of \totalpages}%
}
\newcommand{\horrule}[1]{\rule{\linewidth}{#1}}

\fancypagestyle{firstpage}[plain]% <--- new
{%
\fancyfoot[L,C,R]{}%               <--- new
}
%---------------------------------------------------------------%
\pagestyle{plain}

\title{\normalfont\normalsize
    \horrule{0.5pt} \\[0.4cm]
    \huge \textsc{Testament} \\
    \horrule{2pt} \\[0.5cm]
}

\author{John Doe}
\date{\normalsize\today}

\begin{document}
\maketitle
\thispagestyle{firstpage}% <--- new

\section{Some funny title}
\lipsum[2-12]
\end{document}

enter image description here

9
  • 2
    Oh my God! Why didn’t have found this by myself! Thanks!!
    – Cham
    Mar 7, 2021 at 23:47
  • 1
    @Cham, don't worry (almost) all member here have been (at least) once in similar situation ;-). Happy TeXing!
    – Zarko
    Mar 8, 2021 at 0:06
  • Well, your solution removes the page number at the bottom. I need to keep the footer.
    – Cham
    Mar 8, 2021 at 0:07
  • @cham, sorry, I overlooked this, e.g. read only title of your question. Than you need to define new pagestyle which has header and empty footer. I will ad this ASAP.
    – Zarko
    Mar 8, 2021 at 0:15
  • 1
    @Amir, sorry where you see, that I put definition for mystyle after \begin{Document}? If you have problems with use of fancyhdr package, please ask new question, where please provide MWE which demonstrate your problem. I have problems with understanding your comment ...
    – Zarko
    Jul 18, 2022 at 6:23
4

Off topic, but importent: Do not use package sectsty together with a KOMA-Script class. They are incompatible. Replace

\usepackage{sectsty}
\allsectionsfont{\centering\normalfont\scshape}

by

\renewcommand{\raggedsection}{\centering}
\setkomafont{disposition}{\normalcolor\normalfont\scshape}

Do not abuse \date to change the font size of the date. Replace it by

\setkomafont{date}{\normalsize}

To remove the warning regarding fancyhdr you could use package scrlayer-scrpage:

\documentclass[12pt,letterpaper,twoside]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{microtype}
\usepackage[total={6.25in,10in},left=1.25in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{lipsum}
\usepackage[page]{totalcount}

\usepackage[headsepline]{scrlayer-scrpage}% sets page style scrheadings automatically
\clearpairofpagestyles
\chead{Some title in the header}
\ofoot*{\pagemark}
\renewcommand{\pagemark}{\usekomafont{pagenumber}{Page \thepage~of \totalpages}}
\setkomafont{pageheadfoot}{\normalcolor\normalfont}
\addtokomafont{pagehead}{\scshape}

\renewcommand{\raggedsection}{\centering}
\setkomafont{disposition}{\normalcolor\normalfont\scshape}

\newcommand{\horrule}[1]{\rule{\linewidth}{#1}}

\title{\normalfont\normalsize
    \horrule{0.5pt} \\[0.4cm]
    \huge \textsc{Testament} \\
    \horrule{2pt} \\[0.5cm]
}

\author{John Doe}
\addtokomafont{date}{\normalsize}

\begin{document}
\maketitle
\section{Some funny title}
\lipsum[2-12]
\end{document}

enter image description here

4
  • Nice answer! +1!
    – Zarko
    Mar 8, 2021 at 14:09
  • How can we add a rule to the footers (like the rule for the header), but no rule at the bottom of the first page?
    – Cham
    Mar 8, 2021 at 15:46
  • 1
    Aah! For the question in the previous comment, we just have to add the option footsepline, to the scrlayer-scrpage package. Works like a charm!
    – Cham
    Mar 8, 2021 at 17:44
  • Yes, if you add footsepline to the scrlayer-scrpage options, the rule above the footer is inserted for pages using style scrheadings. If you would need the rule on plain pages (the page with the title header uses plain by default) too, you would have to add option plainfootsepline.
    – esdd
    Mar 8, 2021 at 19:06

You must log in to answer this question.

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