3

For a company document I need a custom titlepage. Only using \maketitle is to simple because there are images and a lot of different text formats. So I created a page using titlepage environment.

But how to add a header and a footer to titlepage that is different then the regular footer? I could "fake" a header but the content on titlepage will always have different sizes so "faking" a footer seems impossible.

%! TEX program = lualatex
% minimal.tex
\documentclass[a4paper, 10pt]{article}

% Packages
\usepackage{fancyhdr}
\usepackage{lastpage}

% Header and Footer
\pagestyle{fancy}
%% Header
\fancyhead{}
\fancyhead[R]{Company Logo}
\setlength\headheight{60pt}
\renewcommand{\headrulewidth}{0pt}

%% Footer
\fancyfoot{}
\fancyfoot[L]{
\footnotesize{Company Footer for all pages except Title page}
}
\fancyfoot[R]{\footnotesize{Seite \thepage{} von \pageref{LastPage}}}
\renewcommand\footrulewidth{0pt}

% Beginn des Dokuments:
\begin{document}

\begin{titlepage}
  \Huge{Title}\\
  \\
  \small{There will be individual content on titlepage.}
\end{titlepage}
\newpage

\section{Content}
Do Something


% Ende des Dokuments:
\end{document}
1
  • Just add this \thispagestyle{fancy} inside the \begin{titlepage} environment. You need another pagestyle for page 2, which you set in the document preamble
    – Sveinung
    Commented Aug 28, 2019 at 15:18

2 Answers 2

3

Well, in your code are some issues:

  1. Commands like \Huge or \small are switches, so the correct use in your case would be something like that:

      {\Huge Title}\\ % <===================================================
    
  2. To get a (new defined) special footer and header for your titlepage you need to add the command \thispagestyle{titlepage} inside your environment titlepage and

  3. you need to define a special header-footer for your titlepage like:

    \fancypagestyle{titlepage}{% <==========================================
      \fancyhf{}% <========================================= Clear header/footer
      \fancyhead[R]{Company Logo}
      \renewcommand{\headrulewidth}{0pt}
      \renewcommand\footrulewidth{0pt}
    }
    
  4. Please see that I moved \setlength\headheight{60pt} outside the defined header-footer-styles (so we need it only for one time) ...

Please see the corrected MWE

%! TEX program = lualatex
% minimal.tex
\documentclass[a4paper, 10pt]{article}

% Packages
\usepackage{lastpage}
\usepackage{fancyhdr}

\setlength\headheight{60pt} % <=========================================
\fancypagestyle{titlepage}{% <==========================================
  \fancyhf{}% <========================================= Clear header/footer
  \fancyhead[R]{Company Logo}
  \renewcommand{\headrulewidth}{0pt}
  \renewcommand\footrulewidth{0pt}
}

% Header and Footer
\pagestyle{fancy}
%% Header
\fancyhead{}
\fancyhead[R]{Company Logo}
\renewcommand{\headrulewidth}{0pt}

%% Footer
\fancyfoot{}
\fancyfoot[L]{
\footnotesize{Company Footer for all pages except Title page}
}
\fancyfoot[R]{\footnotesize{Seite \thepage{} von \pageref{LastPage}}}
\renewcommand\footrulewidth{0pt}


\begin{document}

\begin{titlepage}
  \thispagestyle{titlepage} % <=========================================
  {\Huge Title}\\ % <===================================================
  \\
  {\small There will be individual content on titlepage.} % <===========
\end{titlepage}
\clearpage

\tableofcontents

\section{Content}
Do Something

\section{introduction}
Do Something

% Ende des Dokuments:
\end{document}

and its result:

resulting pdf

0

The definition of \titlepage is:

\if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\newpage\fi
\thispagestyle{empty}\setcounter {page}\@ne

which is basically done to remove the headers and footers ! Hence do not use \titlepage ! If you still cant some grouping, use another environment like minipage or \begingroup and \endgroup, or even braces {}.

You must log in to answer this question.

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