1

I have been racking my brains over how in bloody hell can you have a different header for the title (or first) page of a document.

I am not asking here how I can not have a header by clearing the page style for this page using \thispagestyle{plain} or something of the sort but how can I have a different header just for the very first page.

Please help as I have a deadline to meet.

So far, I have not been able to find anything useful on TeX.SE.

Here is some of my code to give you some idea of what I want to achieve:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[margin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{csc}
\pagestyle{fancy}
\fancyhead[L]{**Left Header for all pages**}\fancyhead[R]{**Right Header for all pages**}
\lhead{**Left Header for just the first page**}
\rhead{**Right Header for just the first page**}
\title{Problem Set 1}
        \author{MyBloodyName}
\date{January 31, 2017}
\begin{document}
    \maketitle
    \newpage
    Easier?
\end{document}
  • 1
    We have a wuestion: hiw to customize my titlepage, please have a look at it. Also please have a look at the segment title creation of the latex wikibook. – Johannes_B Feb 1 '17 at 11:25
5

You can use \fancypagestyle to define a new page style and \thispagestyle to use it for only the current page:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[margin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{graphicx}
%\usepackage{csc}% unknown package
\pagestyle{fancy}
\fancyhead[L]{**Left Header for all pages**}
\fancyhead[R]{**Right Header for all pages**}
\fancypagestyle{firstpage}{%
  \lhead{**Left Header for just the first page**}
  \rhead{**Right Header for just the first page**}
}
\title{Problem Set 1}
\author{MyBloodyName}
\date{January 31, 2017}
\begin{document}
    \maketitle
    \thispagestyle{firstpage}
    \newpage
    Easier?
\end{document}

Nevertheless, this can only be done, if you do not really use a titlepage but a title head on the first page. If you want a title page, you have to patch the page style into, e.g., the titlepage environment:

\documentclass[12pt,titlepage]{article}
\usepackage{amsmath}
\usepackage[margin=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{fancyhdr}
\usepackage{hyperref}
\usepackage{graphicx}
%\usepackage{csc}% unknown package
\pagestyle{fancy}
\fancyhead[L]{**Left Header for all pages**}
\fancyhead[R]{**Right Header for all pages**}
\fancypagestyle{firstpage}{%
  \fancyhf{}% clear default for head and foot
  \lhead{**Left Header for just the first page**}
  \rhead{**Right Header for just the first page**}
}
\usepackage{xpatch}
\xapptocmd{\titlepage}{\thispagestyle{firstpage}}{}{}

\title{Problem Set 1}
\author{MyBloodyName}
\date{January 31, 2017}
\begin{document}
    \maketitle
    Easier?
\end{document}
  • Thanks so much! I'd been at it for hours! For the unknown package csc, I have a csc.sty file for it. Would you also happen to know how to install the package to TeX Live? I can't find the directory for the packages. – HKT Feb 1 '17 at 22:31
  • @HKT Installation of packages is another question and should not be a comment to this answer. – Schweinebacke Feb 2 '17 at 10:21
1

\maketitle is pretty limited, it is a hard coded title including the head and foot (empty).

You can design your own titlepage from scratch. A few explanations can be found in How to custmize my titlepage and the LaTeX wikibook. Have a look at the bottom of the wikibook page, you can find some links with example title pages there.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage[margin=2.5cm,headheight=15pt]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{fancyhdr}
\usepackage{graphicx}
%\usepackage{csc}
\pagestyle{fancy}
\fancyhead[L]{**Left Header for all pages**}
\fancyhead[R]{**Right Header for all pages**}
\title{Problem Set 1}
\author{MyBloodyName}
\date{January 31, 2017}
\usepackage{hyperref}
\begin{document}
\begin{titlepage}
    \setlength{\parindent}{0pt}
    \vspace*{-3.8\baselineskip}
    Wombat \hfill Capybara
    \begin{center}
    \vspace{.1\textheight}
    {\huge\bfseries Probem Set 1 \par}
    \bigbreak
    {\bfseries\large Mr. Walter Wombat\par}
    \bigbreak
    January 31, 2017
\end{center}
\end{titlepage}
Easier?
\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.