2

I am using \documentclass[titlepage]{article} in combination with fancyhdr

\documentclass[titlepage]{article}

\usepackage{fancyhdr}

\makeatletter         

\pagestyle{fancy}

\lhead{}
\rhead{Header Text}
\cfoot{}
\rfoot{Page \thepage/\pageref{LastPage}}
% no line
\renewcommand{\headrulewidth}{0pt}

\begin{document}

% on the first page there is an implicit \thispagestyle{plain}: https://tex.stackexchange.com/questions/439529/removing-the-footer-on-the-first-page
\thispagestyle{empty}

% Custom title page
\begin{titlepage}
The title page
\end{titlepage}

\section*{First section}

In the result I get

  • A title page without headers and footers (page 0)
  • A first page with the plain headers and footer style (page 1)
  • A second page with the fancy headers

Without a titlepage the \thispagestyle{empty} was working. Where do I have to put it in combination with titlepage?

Here is a minimal compilable example (has some text as it have to be be two pages long):

\documentclass[titlepage]{article}

\usepackage[main=german,english]{babel}
\usepackage[a4paper, margin=2.2cm]{geometry}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{tabularx}

% allows the input of UTF-charactes (e.g., umlauts and symbols)
\usepackage[utf8x]{inputenc}

% reduce the spacing in bullet lists
\usepackage{enumitem}
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt}

% Arial is the official ETH font
\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

% Dots in the ToC even for sections
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

\title{Title}

\makeatletter         

\pagestyle{fancy}

\lhead{}
\rhead{Title}
\cfoot{}
\rfoot{Seite \thepage/\pageref{LastPage}}
% no line
\renewcommand{\headrulewidth}{0pt}

\begin{document}

% on the first page there is an implicit \thispagestyle{plain}: https://tex.stackexchange.com/questions/439529/removing-the-footer-on-the-first-page
\thispagestyle{empty}

% Custom title page
\begin{titlepage}
\raggedright
\begin{tabularx}{\textwidth}{@{}X@{}r@{}}

% ETH logo
LOGO &

% contact information

\begin{tabular}[t]{l}
\textbf{Contact 1} \\
\textbf{Contact 2} \\
\\
Address \\

\end{tabular} \\

\end{tabularx}

\vspace{12ex}

{\Large \bfseries \sffamily Subtitle }\\[2ex]
{\huge \bfseries \sffamily \@title }\\[4ex] 

Text\\[4ex]

\begin{tabular}{@{}ll}
\textbf{Datum}     & \@date \\
\textbf{Version}   & 0.1 \\
\textbf{Autor(en)} & Name
\end{tabular}
\end{titlepage}


\tableofcontents

\section{Section}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris posuere turpis velit. Duis sed enim vitae est interdum consequat in ut tortor. Aenean pharetra sagittis cursus. Aenean fringilla imperdiet lectus, eu dapibus libero mattis suscipit. Nam nec dolor at orci tempus malesuada. Mauris ut lectus urna. Morbi sagittis accumsan nibh, sed sagittis nisi pretium vel. Aenean fringilla magna nunc, et semper nisi euismod non.

Nullam pulvinar purus eget lorem imperdiet, sit amet aliquet urna malesuada. Sed malesuada felis arcu, sed accumsan libero placerat a. Phasellus porta ex non lacinia elementum. Vestibulum consectetur sodales malesuada. Duis sodales, nisl eu semper viverra, lorem diam imperdiet justo, in venenatis odio urna eu massa. Proin malesuada lacinia massa, a vehicula eros convallis sit amet. Ut nec commodo dolor. Suspendisse eget pulvinar ante, sed congue tortor. Fusce sit amet dolor massa.

Integer a diam eu elit interdum lacinia. In quis porta justo, id interdum risus. Fusce accumsan iaculis ipsum, eu porttitor velit pretium vitae. Proin bibendum arcu ex, in efficitur metus ultricies sit amet. Phasellus mollis consectetur dui, sit amet facilisis augue gravida nec. Curabitur sollicitudin, augue vel malesuada maximus, diam nunc convallis ex, nec ultrices massa ipsum vel libero. Maecenas aliquet aliquam fringilla. Nam in finibus nisi. Morbi sit amet leo tellus. Donec augue leo, dapibus ut luctus non, condimentum sed risus.

Quisque eget ipsum venenatis mauris rutrum posuere in at nisl. Vestibulum id interdum leo, vel lacinia massa. Proin faucibus ipsum ut risus vulputate euismod. Proin id posuere nisi. Nam cursus augue et viverra egestas. Donec sagittis libero eu massa sollicitudin tempor. Nulla scelerisque et lectus eu dictum. Nulla facilisi.

Maecenas in maximus nisi. Quisque tristique eros eu turpis luctus egestas. Nulla rhoncus et erat in dignissim. Cras dolor nibh, aliquet et sodales at, semper sed diam. Nullam ex diam, lobortis id bibendum nec, dictum vel lorem. Phasellus elit orci, iaculis at ligula tempus, laoreet lacinia orci. Nulla nulla arcu, rhoncus ac malesuada vel, consequat eget nibh. Nunc luctus hendrerit augue nec aliquet. Sed malesuada diam sed turpis consequat, at tempus nisi dapibus.

Nunc iaculis eget lectus at feugiat. Donec nisi magna, bibendum non eros vitae, maximus blandit velit. Proin ullamcorper felis vel leo pretium, malesuada aliquam est blandit. Proin eros felis, lacinia nec justo id, cursus fermentum nisi. Sed tincidunt urna vel ipsum sagittis, et vestibulum dui pharetra. Quisque magna augue, sodales at ultrices ac, interdum eu mauris. Curabitur pretium purus sed lacus maximus placerat. Phasellus tempus, purus sed finibus rhoncus, purus leo placerat justo, non dignissim massa augue nec lectus. Proin ac congue mauris. Proin ornare tortor urna, fermentum bibendum elit cursus id.

Nullam accumsan scelerisque ligula eget faucibus. Nulla dapibus ante ut dui scelerisque suscipit. Vestibulum faucibus dolor ut lobortis ultricies. Proin tempor velit et dignissim hendrerit. Ut efficitur scelerisque eros viverra dapibus. Ut finibus magna sit amet arcu pharetra aliquet. Etiam in lorem eget velit condimentum varius. Ut sed ligula aliquam, eleifend nunc et, tempus neque.

 Sed non scelerisque purus, quis placerat ex. Sed feugiat odio purus, non porta libero vehicula id. Phasellus feugiat, lorem at rhoncus posuere, justo nulla sagittis eros, quis accumsan dolor libero et tortor. Suspendisse ac suscipit elit. Vivamus molestie sed nisi sed malesuada. Integer nibh neque, mattis sit amet fringilla nec, pharetra consectetur urna. Praesent nulla libero, gravida ac lacus quis, rutrum egestas ex. Sed egestas interdum sapien, sed congue purus tincidunt eu. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.

Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean eu euismod mi. Fusce tincidunt nisl scelerisque consequat suscipit. Aenean volutpat lectus eget mi maximus, ac sollicitudin metus pulvinar. Quisque id aliquet turpis. Nulla facilisi. Sed finibus elit in leo elementum, eu ultrices dolor accumsan. Nam non nunc ipsum. Donec elementum tincidunt auctor. Donec sit amet pretium ex, in placerat urna. Nunc a orci sed mauris fringilla tempus et vel arcu. Mauris diam nulla, maximus quis vestibulum dignissim, porta et tellus. Integer in dolor ipsum. Vivamus luctus justo a purus euismod fermentum.

Ut pretium nulla a pharetra scelerisque. Suspendisse vitae tempor magna. Donec ornare, ipsum sit amet interdum consectetur, dolor augue auctor est, sit amet feugiat lectus tortor at enim. Proin est est, laoreet sollicitudin eros sit amet, tristique feugiat nunc. Duis rhoncus at ante sed luctus. Curabitur non faucibus massa. In tristique posuere sem ac dictum. Vivamus ullamcorper ultricies diam, ut sagittis mauris.

Maecenas tempor dolor eu diam rhoncus semper. Nunc tempor consequat lacus id maximus. Proin enim sapien, blandit sed mattis nec, vestibulum id nisi. Suspendisse finibus metus leo. Suspendisse tempus blandit nunc at pretium. Phasellus quis nulla pellentesque, commodo neque eget, fermentum massa. Vivamus eu lorem nunc. Etiam aliquam massa at metus ultrices malesuada. Maecenas tincidunt lacus eget sodales pulvinar. Donec sagittis, lectus non egestas finibus, ante ante consequat ante, in hendrerit quam magna nec ex. Nullam tincidunt, libero et molestie euismod, ipsum neque aliquet justo, a fringilla tellus orci in tortor. Curabitur lorem nulla, sollicitudin sit amet molestie quis, rutrum at turpis.

Mauris rhoncus faucibus laoreet. Suspendisse enim nisl, blandit non arcu imperdiet, dapibus aliquam augue. Duis eu leo eros. Integer nisl ipsum, porta non dapibus at, blandit non odio. Suspendisse id nibh non mi molestie bibendum eu posuere eros. Donec finibus, enim et placerat blandit, arcu elit feugiat mauris, facilisis commodo est diam sed ligula. Praesent vestibulum feugiat porta. Aliquam erat volutpat. Cras tincidunt tempus lacus id lacinia. Etiam augue lorem, feugiat eu lobortis quis, tincidunt ac mauris.

Aliquam consectetur ante ac urna tincidunt aliquet. Quisque nunc neque, molestie vitae sem nec, feugiat volutpat nisl. Donec rutrum molestie lobortis. Aliquam fringilla feugiat quam, ut consectetur mi ultricies a. Vivamus eget hendrerit tellus, non imperdiet nunc. Proin ullamcorper feugiat eros, quis interdum eros lobortis et. Vivamus eu efficitur massa. Quisque magna diam, vehicula at aliquam nec, tempor eget odio.

\end{document}
  • The fancyhdr was missing because of copy and paste. If I remove the \makeatletter I get tons of errors in the title page (for example You can't use \spacefactor in vertical mode` – Matteo Jul 6 '18 at 16:11
  • Shouldn't \thispagestyle{empty} be inside the titlepage environment? Maybe I just don't understand what you want: what should the result be, as far as you're concerned? – cfr Jul 6 '18 at 22:18
  • Please edit your question to make your code compilable. You certainly need to end the document environment. You probably also forgot a label, though that won't stop compilable, obviously. – cfr Jul 6 '18 at 22:19
  • @cfr I added a complete compilable example – Matteo Jul 7 '18 at 6:50
2

The tocloft package does

\tocloftpagestyle{plain}

It's usually better to load the package with the titles option, which suppresses its attempt to redefine \tableofcontents.

In the code below I changed the order of loading of the packages, also separating the setting part: it's better to have all settings together, rather than scattered here and there.

There is no need for tabularx, which would misalign the logo and the contact information anyhow.

Avoid utf8x, which is unmaintained and has some “peculiar” features; \usepackage[utf8]{inputenc} is even redundant in the most recent LaTeX release (2018-04-01). Don't forget \usepackage[T1]{fontenc} that's mandatory if you write in German; are you sure you don't want the adaptation to neue Rechtschreibung, that is, ngerman?

\documentclass[titlepage]{article}
\usepackage[a4paper, margin=2.2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[main=german,english]{babel}

\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage[titles]{tocloft}
\usepackage{helvet}

\usepackage{lipsum} % easier to produce lipsum text

% page style
\pagestyle{fancy}
\fancyhf{}% clear all fields
\fancyhead[R]{Title}
\fancyfoot[R]{Seite \thepage/\pageref{LastPage}}
\renewcommand{\headrulewidth}{0pt}% no line

% Dots in the ToC even for sections
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
% reduce the spacing in bullet lists
\setitemize{noitemsep,topsep=0pt,parsep=0pt,partopsep=0pt}

% Arial is the official ETH font
\renewcommand{\familydefault}{\sfdefault}


% metadata
\title{Title}

\begin{document}


% Custom title page
\begin{titlepage}
\raggedright

% ETH logo
\includegraphics[width=3cm,valign=t]{example-image}\hfill
% contact information
\begin{tabular}[t]{@{}l@{}}
\textbf{Contact 1} \\
\textbf{Contact 2} \\
\\
Address
\end{tabular}

\vspace{12ex}

{\Large\bfseries Subtitle\\}
\makeatletter
{\huge \bfseries \@title\\[2ex]}
\makeatother

Text\\[4ex]

\begin{tabular}{@{}ll}
\textbf{Datum}     & \@date \\
\textbf{Version}   & 0.1 \\
\textbf{Autor(en)} & Name
\end{tabular}
\end{titlepage}

\pagestyle{fancy}

\tableofcontents

\section{Section}

\lipsum[1-13]

\end{document}

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.