# Page Style Fancy Bibliography Format

LaTeX has some predetermined styles that change the way the header and the footer are displayed. The footer and the header can also be customized to fit any particular layout. This article explains how.

## Introduction

The information displayed in the footer and the header of a document depends on the page style currently active, these page styles are more notorious in the book document class:

\documentclass[a4paper,12pt,twoside]{book}\usepackage[english]{babel}\usepackage[utf8]{inputenc}   \pagestyle{headings}   \begin{document}\chapter{Sample Chapter}\section{New section}   Hello, here is some text without a meaning. This text should show what aprinted text will look like at this place. If you read this text, you will get noinformation. Really? Is there no information? Is there a diㄦence betweenthis text and some nonsense like \Huardest gefburn"? Kjift { not at all!...   \end{document}

The command sets the page style called headings to the current document. You can see more page styles in the next section

Open an example in ShareLaTeX

## Standard page styles

The standard page styles are invoked in LaTeX by means of the command:

The myheadings pagestyle displays the page number on top of the page in the outer corner.

There are other three page styles:

• : Both the header and footer are cleared (blank) in this page style.
• : This is the default style. The header is empty and the footer contains page numbers in the centre.
• : As shown in the introduction,The footer is empty in this page style. The header contains the page number on right side (on even pages) or on left side (on odd pages) along with other user-supplied information; there is an exception for the first page of each chapter, where the footer contains centred page number while the header is blank.

Open an example in ShareLaTeX

## Setting page style for current page only

Sometimes is convenient to specify the page style only for the current page. For instance, to leave a intentionally blank page or to remove the header and footer from the current chapter page:

\chapter{Sample Chapter}\thispagestyle{empty}   Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim }ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit es... \end{document}

Of course, you can replace empty for any of the styles mentioned in the previous section

Open an example in ShareLaTeX

## 

Styles can be modified beyond the standard layouts by means of fancyhdr. Below is an example.

\documentclass{article}\usepackage[english]{babel}\usepackage[utf8]{inputenc}\usepackage{fancyhdr}   \pagestyle{fancy}\fancyhf{}\rhead{Share\LaTeX}\lhead{Guides and tutorials}\rfoot{Page \thepage}   \begin{document}   \section{First Section}   Hello, here is some text without a meaning. This text should show what aprinted text will look like at this place. If you read this text, you will get noinformation. Really? Is there no information? Is there a diㄦence between this ...   \end{document}

To customize the footer and header in your document first import the package fancyhdr with

After that, the "fancy" style is set by . The command clears the header and footer, otherwise the elements of the default "plain" page style will appear.

Below, a description of the rest of the commands and a few more whose usage is similar.

Prints the text included inside the braces on the right side of the header.
Prints the text set inside the braces on the left side of the header.
Similar to the previous commands, in this case the text is centred on the header.
Prints the word "Page" and next the page number which is automatically set by on the right side of the footer. See the reference guide for a list of commands that automatically generate content (Section numbers, chapters and so on).
This prints the parameter passed inside the braces on the left side of the footer.
Similar to the previous two commands, prints its parameter on the centre of the footer.

Open an example of the fancyhdr package in ShareLaTeX

## 

If your document is double-sided, for example a book, and you need to customize the header and the footer, the recommended commands in this case are and with several selectors passed as parameters. Let's see:

\documentclass[a4paper,12pt,twoside]{book}\usepackage[utf8]{inputenc}\usepackage[english]{babel}\usepackage{fancyhdr}   \pagestyle{fancy}\fancyhf{}\fancyhead[LE,RO]{Share\LaTeX}\fancyhead[RE,LO]{Guides and tutorials}\fancyfoot[CE,CO]{\leftmark}\fancyfoot[LE,RO]{\thepage}     \begin{document}   \chapter{Using different page styles}   Lorem ipsum dolor sit amet, consectetur adipiscing ...

The selectors that can be passed, inside brackets, to the commands and are:

• for even page
• for odd page
• for left side
• for centered
• for right side

For instance, will print the text "ShareLaTeX" on the Left side of the header for Even pages, and the Right side for Odd pages.

For more information on the command and used in the previous example see the reference guide.

Open an example of the fancyhdr package in ShareLaTeX

## Decorative lines on header and footer

When you are using fancyhdr in your document, there are two decorative lines on both the header and the footer, the latter has 0pt thickness and hence is not visible. It's easy to change that:


There are two additional lines in this example:

This sets the header line thickness to 2pt.
Sets the footer line thickness to 1pt.

Open an example of the fancyhdr package in ShareLaTeX

## Reference guide

The following commands can be used in the headers and footers to add custom information

• adds number of the current page.
• adds number of the current chapter.
• adds number of the current section.
• adds the word "Chapter" in English or its equivalent in the current language.
• adds name and number of the current top-level structure (for example, Chapter for reports and books classes; Section for articles ) in uppercase letters.
• adds name and number of the current next to top-level structure (Section for reports and books; Subsection for articles) in uppercase letters.

 This module may require a complete rewrite in order to suit its intended audience.You can help rewrite it. Please see the relevant discussion.

Page styles in Latex terms refers not to page dimensions, but to the running headers and footers of a document. These headers typically contain document titles, chapter or section numbers/names, and page numbers.

### Standard page styles

The possibilities of changing the headers in plain Latex are actually quite limited. There are two commands available: will apply the specified style to the current and all subsequent pages, and will only affect the current page. The possible styles are:

 empty Both header and footer are cleared plain Header is clear, but the footer contains the page number in the center. headings Footer is blank, header displays information according to document class (e.g., section name) and page number top right. myheadings Page number is top right, and it is possible to control the rest of the header.

The commands and can be used to set the content of the headings by hand. The following commands placed at the beginning of an article document will set the header of all pages (one-sided) to contain "John Smith" top left, "On page styles" centered and the page number top right:

 \pagestyle{headings}\markright{John Smith\hfill On page styles\hfill}

There are special commands containing details on the running page of the document.

 number of the current page current chapter name printed like "CHAPTER 3. THIS IS THE CHAPTER TITLE" current section name printed like "1.6. THIS IS THE SECTION TITLE" the name chapter in the current language. If this is English, it will display "Chapter" current chapter number current section number

Note that and convert the names to uppercase, whichever was the formatting of the text. If you want them to print the actual name of the chapter without converting it to uppercase use the following command:


Now and will just print the name of the chapter and section, without number and without affecting the formatting. Note that these redefinitions must be inserted after the first call of . The standard book formatting of the is:

 \renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\chaptername\ \thechapter.\ #1}}{}}

Watch out: if you provide long text in two different "parts" only in the footer or only in the header, you might see overlapping text.

Moreover, with the following commands you can define the thickness of the decorative lines on both the header and the footer:

The first line for the header, the second for the footer. Setting it to zero means that there will be no line.

#### Plain pages issue

An issue to look out for is that the major sectioning commands (, or ) specify a . So, if you wish to suppress all styles by inserting a at the beginning of your document, then the style command at each section will override your initial rule, for those pages only. To achieve the intended result one can follow the new section commands with . The command, however, cannot be fixed this way, because it sets the page style, but also advances to the next page, so that cannot be applied to that page. Two solutions:

• simply write in the preamble. This package will make have the same effect as , effectively suppressing page numbering when it is used.
• Use fancyhdr as described below.

The tricky problem when customizing headers and footers is to get things like running section and chapter names in there. Standard LaTeX accomplishes this with a two-stage approach. In the header and footer definition, you use the commands and to represent the current section and chapter heading, respectively. The values of these two commands are overwritten whenever a chapter or section command is processed. For ultimate flexibility, the command and its friends do not redefine and themselves. They call yet another command (, , or ) that is responsible for redefining and , except if they are starred -- in such a case, must be used inside the sectioning command if header and footer lines are to be updated.

Again, several packages provide a solution:

• an alternative one-stage mechanism is provided by the package titleps);
• fancyhdr will handle the process its own way.

### Customizing with fancyhdr

To get better control over the headers, one can use the package fancyhdr written by Piet van Oostrum. It provides several commands that allow you to customize the header and footer lines of your document. For a more complete guide, the author of the package produced this documentation.

To begin, add the following lines to your preamble:

You can now observe a new style in your document.

The needs to be 13.6pt or more, otherwise you will get a warning and possibly formatting issues. Both the header and footer comprise three elements each according to its horizontal position (left, centre or right).

The styles supported by fancyhdr:

• the four LaTeX styles;
• fancy defines a new header for all pages but plain-style pages such as chapters and titlepage;
• fancyplain is the same, but for absolutely all pages.

#### Style customization

The styles can be customized with specific commands. Those two styles may be configured directly, whereas for LaTeX styles you need to make a call to the command.

To set header and footer style, fancyhdr provides three interfaces. They all provide the same features, you just use them differently. Choose the one you like most.

• You can use the following six commands.
 \lfoot[]{}\cfoot[]{}\rfoot[]{}

Hopefully, the behaviour of the above commands is fairly intuitive: if it has head in it, it affects the head etc, and obviously, l, c and r means left, centre and right respectively.

• You can also use the command for header and for footer. They work in the same way, so we'll explain only the first one. The syntax is:

You can use multiple selectors optionally separated by a comma. The selectors are the following:

 E even page O odd page L left side C centered R right side

so CE,RO will refer to the center of the even pages and to the right side of the odd pages.

• is a merge of and , hence the name. There are two additional selectors H and F to specify the header or the footer, respectively. If you omit the H and the F, it will set the fields for both.

These commands will only work for fancy and fancyplain. To customize LaTeX default style you need the command. See below for examples.

For a clean customization, we recommend you start from scratch. To do so you should erase the current pagestyle. Providing empty values will make the field blank. So

will just delete the current heading/footer configuration, so you can make your own.

#### Plain pages

There are two ways to change the style of plain pages like chapters and titlepage.

First you can use the fancyplain style. If you do so, you can use the command inside fancyhdr commands like , etc.

When LaTeX wants to create a page with an empty style, it will insert the first argument of , in all the other cases it will use the second argument. For instance:

It has the same behavior of the previous code, but you will get empty header and footer in the title and at the beginning of chapters.

Alternatively you could redefine the plain style, for example to have a really plain page when you want. The command to use is and the argument can contain all the commands explained before. An example is the following:


In that case you can use any style but fancyplain because it would override your redefinition.

#### Examples

For two-sided, it's common to mirror the style of opposite pages, you tend to think in terms of inner and outer. So, the same example as above for two-sided is:

This is effectively saying author name is top outer, today's date is top inner, and current page number is bottom outer. Using can make it shorter:

 \fancyhf[HLE,HRO]{Author's Name}\fancyhf[HRE,HLO]{\today}\fancyhf[FLE,FRO]{\thepage}

Here is the complete code of a possible style you could use for a two-sided document:

Using one can additionally define multiple styles for one's document that are easy to switch between. Here's a somewhat complicated example for a two-sided book style:


### Customizing with scrlayer-scrpage

Package is part of the KOMA-script bundle. Using this package to customize the headers and footers is recommended with every KOMA-script class. The package can be used with the standard classes as well.

\documentclass{book}\usepackage{scrlayer-scrpage}\usepackage{mwe}\begin{document}\chapter{Manta Ray}\blindtext\section{Taxonomy}\blindtext[10]\chapter{Mobula}\blindtext\section{Life style}\blindtext[10]\end{document}

Just loading the package doesn't change the default behavior. Chapter titles are on left hand pages, the section titles on right hand pages. The page number appears in the outer head.

Now, what can we do to customize the headers and footers?

We can use the commands that are available with the package, they are described in more detail in the package documentation.

Following a few examples that may be needed in real documents.

#### How can one move the page number to the center of the footer and remove the capitalization of the header?

\documentclass{book}\usepackage{mwe}\usepackage[markcase=noupper% remove the uppercasing ]{scrlayer-scrpage}\ohead{}% clear the outer head\cfoot*{\pagemark}% the pagenumber in the center of the foot, also on plain pages\begin{document}\chapter{Manta Ray}\blindtext\section{Taxonomy}\blindtext[10]\chapter{Mobula}\blindtext\section{Life style}\blindtext[10]\end{document}

Both, header and footer are separated in an inner, center, and outer part, which can be set independently. The asterisk defines the same content to be on pages as well. Usually, pages on which a chapter starts, use the style.

#### How can I have my name and title of my thesis in the inner foot?

\documentclass{book}\usepackage{mwe}\usepackage[markcase=noupper% remove the uppercasing ]{scrlayer-scrpage}\ohead{}% clear the outer head\ofoot*{\pagemark}% the pagenumber in the outer part of the foot, also on plain pages\ifoot*{Walter Wombat\\ Is life on Mars possible?}% Name and title beneath each other in the inner part of the foot\setlength{\footheight}{24.0pt}\begin{document}\chapter{Manta Ray}\blindtext\section{Taxonomy}\blindtext[10]\chapter{Mobula}\blindtext\section{Life style}\blindtext[10]\end{document}

#### How to change to font style in headers and footers?

The package provides an interface similar to the KOMA-script classes. You can add font attribute to the header and footer. The page number can be set independently.

 \documentclass{book}\usepackage{mwe}\usepackage{xcolor}\usepackage[markcase=noupper% remove the uppercasing ]{scrlayer-scrpage}\ohead{}% clear the outer head\addtokomafont{pagehead}{\sffamily}\addtokomafont{pagefoot}{\tiny}% Making the foot extra tiny to demonstrate\addtokomafont{pagenumber}{\large\bfseries\color{red!80!black}}% that the page number can be controlled on its own. \ofoot*{\pagemark}% the pagenumber in the outer part of the foot, also on plain pages\ifoot*{Walter Wombat\\ Is life on Mars possible?}% Name and title beneath each other in the inner part of the foot\setlength{\footheight}{24.0pt}\begin{document}\chapter{Manta Ray}\blindtext\section{Taxonomy}\blindtext[10]\chapter{Mobula}\blindtext\section{Life style}\blindtext[10]\end{document}

### Page n of m

Some people like to put the current page number in context with the whole document. LaTeX only provides access to the current page number. However, you can use the lastpage package to find the total number of pages, like this:

 \usepackage{lastpage} ... \cfoot{\thepage\ of \pageref{LastPage}}

Note the capital letters. Also, add a backslash after to ensure adequate space between the page number and 'of'. And recall, when using references, that you have to run LaTeX an extra time to resolve the cross-references.

### Alternative packages

Other packages for page styles are scrpage2, very similar to fancyhdr, and titleps, which takes a one-stage approach, without having to use or .