Sunteți pe pagina 1din 12

Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

Documentation Home  Search help library....


(/learn/Main_Page)
Learn LaTeX in 30
minutes (/learn
/Learn_LaTeX_in_30_minutes) Headers and footers
ShareLaTeX
guides
LATEX has some predetermined styles that change the way the
Creating a document
header and the footer are displayed. The footer and the header
in ShareLaTeX (/learn
can also be customized to �t any particular layout. This article
/Creating_a_document_in_ShareLaTeX)
explains how.
Uploading a project
(/learn
/Uploading_a_project)
Copying a project
Contents
(/learn 1 Introduction
/Copying_a_project) 2 Standard page styles
Creating a project 3 Setting page style for current page only
from a template 4 Style customization in single-sided documents
(/learn
5 Style customization in double-sided documents
/Creating_a_project_from_a_template)
6 Decorative lines on header and footer
Including images in
7 Reference guide
ShareLaTeX (/learn
8 Further reading
/Including_images_in_ShareLaTeX)
Exporting your work
from ShareLaTeX
(/learn
Introduction
/Exporting_your_work_from_ShareLaTeX)
The information displayed in the footer and the header of a
Using bibliographies in document depends on the page style currently active, these
ShareLaTeX (/learn page styles are more notorious in the book document class:
/Using_bibliographies_in_ShareLaTeX)
Sharing your work
with others (/learn
/Sharing_your_work_with_others)
Debugging
Compilation
© 2018 timeout
ShareLaTeX Terms (/tos) Privacy (/privacy_policy) Security (/security) Contact ()

1 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

errors (/learn
\documentclass[a4paper,12pt,twoside]{book}
About (/about) Blog (/blog) Universities (/university?ref=footer)
/Debugging_Compilation_timeout_errors)
\usepackage[english]{babel}
Knowledge Base \usepackage[utf8]{inputenc}
(/learn
 (http://www.twitter.com/sharelatex)
\pagestyle{headings}
/Kb/Knowledge_Base)
 (http://www.facebook.com/pages/ShareLaTeX/301671376556660)
\begin{document}
LaTeX Basics \chapter{Sample Chapter}
 (https://plus.google.com/115074691861228882827)
\section{New section} (https://github.com/sharelatex/sharelatex)
Creating your �rst
LaTeX document Hello, here is some text without a meaning.
(/learn This text should
/Creating_a_document_in_LaTeX)show what aprinted text will look like at this
place. If you
Choosing a LaTeX read this text, you will get noinformation.
Compiler (/learn Really? Is there
/Choosing_a_LaTeX_Compiler) no information? Is there a diㄦence
Paragraphs and new betweenthis text and some
nonsense like \Huardest gefburn"? Kjift { not
lines (/learn
at all!...
/Paragraphs_and_new_lines)
Bold, italics and \end{document}
underlining (/learn
/Bold,_italics_and_underlining)
Lists (/learn/Lists)
Errors (/learn/Errors)

Mathematics
Mathematical
expressions (/learn
/Mathematical_expressions)
Subscripts and
superscripts (/learn
/Subscripts_and_superscripts)
Brackets and
Parentheses (/learn
/Brackets_and_Parentheses)
(/learn/File:HeadersFootersEx1.png)
Fractions and
Binomials (/learn The command \pagestyle{headings} sets the page style
/Fractions_and_Binomials)
called headings to the current document. You can see more
Aligning Equations page styles in the next section
(/learn
/Aligning_equations)   Open an example in ShareLaTeX
Operators (/learn (https://www.sharelatex.com/project/new/template?zipUrl=

2 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

/Operators) /project/534173dadd7cb62b32b6f702/download/zip&
Spacing in math mode templateName=Standard_headers_footers&compiler=pd�atex)
(/learn
/Spacing_in_math_mode)
Standard page styles
Integrals, sums and
limits (/learn The standard page styles are invoked in LATEX by means of the
/Integrals,_sums_and_limits) command:
Display style in math
\pagestyle{''style''}
mode (/learn
/Display_style_in_math_mode)
\pagestyle{myheadings}
List of Greek letters
and math symbols
(/learn
/List_of_Greek_letters_and_math_symbols)
Mathematical fonts
(/learn
/Mathematical_fonts)

Figures and
tables
Inserting Images
(/learn
/Inserting_Images)
Tables (/learn/Tables)
Positioning Images
(/learn/File:HeadersFootersEx2.png)
and Tables (/learn
/Positioning_images_and_tables)
The myheadings pagestyle displays the page number on top of
Lists of Tables and the page in the outer corner.
Figures (/learn
/Lists_of_tables_and_�gures) There are other three page styles:

Drawing Diagrams empty: Both the header and footer are cleared (blank) in
Directly in LaTeX
this page style.
(/learn
/Picture_environment) plain: This is the default style. The header is empty and
TikZ package (/learn the footer contains page numbers in the centre.
/TikZ_package)
myheadings: As shown in the introduction,The footer is
References and empty in this page style. The header contains the page
Citations number on right side (on even pages) or on left side (on

Bibliography
odd pages) along with other user-supplied information;
management in LaTeX there is an exception for the �rst page of each chapter,

3 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

(/learn where the footer contains centred page number while the
/Bibliography_management_in_LaTeX)
header is blank.
Bibliography
management with
  Open an example in ShareLaTeX
biblatex (/learn (https://www.sharelatex.com/project/new/template?zipUrl=
/project/534173dadd7cb62b32b6f702/download/zip&
/Bibliography_management_in_LaTeX)
Biblatex bibliography templateName=Standard_headers_footers&compiler=pd�atex)
styles (/learn
/Biblatex_bibliography_styles) Setting page style for current page
Biblatex citation styles only
(/learn
/Biblatex_citation_styles) Sometimes is convenient to specify the page style only for the
Bibliography current page. For instance, to leave a intentionally blank page or
management with to remove the header and footer from the current chapter page:
natbib (/learn
/Bibliography_management_with_natbib)
\chapter{Sample Chapter}
\thispagestyle{empty}
Natbib bibliography
styles (/learn Lorem ipsum dolor sit amet, consectetur
/Natbib_bibliography_styles) adipiscing elit, sed do
Natbib citation styles eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim
(/learn
}ad minim veniam, quis nostrud exercitation
/Natbib_citation_styles) ullamco laboris nisi
Bibliography ut aliquip ex ea commodo consequat. Duis aute
management with irure dolor in
reprehenderit in voluptate velit es...
bibtex (/learn
\end{document}
/Bibliography_management_with_bibtex)
Bibtex bibliography
styles (/learn
/Bibtex_bibliography_styles)

Languages
International language
support (/learn
/International_language_support)
Quotations and
quotation marks
(/learn
/Typesetting_quotations)
Arabic (/learn/Arabic)
Chinese (/learn
/Chinese)

4 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

French (/learn/French)
German (/learn
/German)
Greek (/learn/Greek)
Italian (/learn/Italian)
Japanese (/learn
/Japanese)
Korean (/learn/Korean)
Portuguese (/learn
/Portuguese)
Russian (/learn
/Russian)
Spanish (/learn
/Spanish)

Document
structure
Sections and chapters
(/learn
/Sections_and_chapters)
Table of contents
(/learn
/Table_of_contents)
Cross referencing
sections and
equations (/learn
/Cross_referencing_sections_and_equations)
(/learn/File:HeadersFootersEx3.png)
Indices (/learn/Indices)
Of course, you can replace empty for any of the styles
Glossaries (/learn
mentioned in the previous section
/Glossaries)
Nomenclatures (/learn   Open an example in ShareLaTeX
/Nomenclatures) (https://www.sharelatex.com/project/new/template?zipUrl=
Management in a large /project/534173dadd7cb62b32b6f702/download/zip&
project (/learn templateName=Standard_headers_footers&compiler=pd�atex)
/Management_in_a_large_project)
Multi-�le LaTeX
Style customization in single-sided
projects (/learn/Multi-
�le_LaTeX_projects)
documents
Hyperlinks (/learn Styles can be modi�ed beyond the standard layouts by means of
/Hyperlinks) fancyhdr. Below is an example.

5 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

Formatting
\documentclass{article}
Lengths in LATEX \usepackage[english]{babel}
(/learn
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
/Lengths_in_LaTeX)
Headers and footers \pagestyle{fancy}
(/learn \fancyhf{}
/Headers_and_footers)
\rhead{Share\LaTeX}
\lhead{Guides and tutorials}
Page numbering \rfoot{Page \thepage}
(/learn
/Page_numbering) \begin{document}

Paragraph formatting \section{First Section}


(/learn
/Paragraph_formatting) Hello, here is some text without a
meaning. This
Line breaks and blank
text should show what aprinted text will
spaces (/learn look like at
/Line_breaks_and_blank_spaces) this place. If you read this text, you will
Text alignment (/learn
get noinformation.
Really? Is there no information? Is there a
/Text_alignment)
diㄦence between
Page size and margins this ...
(/learn
/Page_size_and_margins) \end{document}
Single sided and
double sided
documents (/learn
/Single_sided_and_double_sided_documents)
Multiple columns
(/learn
/Multiple_columns)
Counters (/learn
/Counters)
Code listing (/learn
/Code_listing)
Code Highlighting with
minted (/learn
/Code_Highlighting_with_minted)
Using colours in LaTeX
(/learn
/Using_colours_in_LaTeX)
Footnotes (/learn (/learn/File:HeadersFootersEx4.png)
/Footnotes)
To customize the footer and header in your document �rst

6 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

Margin notes (/learn import the package fancyhdr with


/Margin_notes)
\usepackage{fancyhdr}
Fonts
After that, the "fancy" style is set by \pagestyle{fancy}. The
Font sizes, families, command \fancyhf{} clears the header and footer, otherwise
and styles (/learn the elements of the default "plain" page style will appear.
/Font_sizes,_families,_and_styles)
Font typefaces (/learn Below, a description of the rest of the commands and a few
/Font_typefaces) more whose usage is similar.
Supporting modern \rhead{Share\LaTeX}
fonts with XƎLATEX
Prints the text included inside the braces on the right side of the
(/learn/XeLaTeX)
header.

Presentations
\lhead{Guides and tutorials}
Beamer (/learn
Prints the text set inside the braces on the left side of the
/Beamer)
header.
Powerdot (/learn
/Powerdot)
\chead{ }
Posters (/learn
Similar to the previous commands, in this case the text is
/Posters)
centred on the header.

Commands
\rfoot{Page \thepage}
Commands (/learn
Prints the word "Page" and next the page number which is
/Commands)
automatically set by \thepage on the right side of the footer.
Environments (/learn
See the reference guide for a list of commands that
/Environments)
automatically generate content (Section numbers, chapters and

Field speci�c so on).

Theorems and proofs


\lfoot{ }
(/learn
This prints the parameter passed inside the braces on the left
/Theorems_and_proofs)
side of the footer.
Chemistry formulae
(/learn
/Chemistry_formulae) \cfoot{ }

Feynman diagrams
Similar to the previous two commands, prints its parameter on
(/learn the centre of the footer.
/Feynman_diagrams)
Molecular orbital   Open an example of the fancyhdr package in ShareLaTeX
diagrams (/learn (https://www.sharelatex.com/project/new/template?zipUrl=
/Molecular_orbital_diagrams) /project/53440a3824874b0852c13d61/download/zip&

7 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

Chess notation (/learn templateName=OneSidedHederFooter&compiler=pd�atex)


/Chess_notation)
Knitting patterns Style customization in double-sided
(/learn
/Knitting_patterns)
documents
CircuiTikz package If your document is double-sided, for example a book, and you
(/learn need to customize the header and the footer, the recommended
/CircuiTikz_package) commands in this case are \fancyhead and \fancyfoot with
Pgfplots package several selectors passed as parameters. Let's see:
(/learn
/Pgfplots_package) \documentclass[a4paper,12pt,twoside]{book}
Typing exams in LaTeX \usepackage[utf8]{inputenc}
\usepackage[english]{babel}
(/learn
\usepackage{fancyhdr}
/Typing_exams_in_LaTeX)
Knitr (/learn/Knitr) \pagestyle{fancy}
\fancyhf{}
Attribute Value
\fancyhead[LE,RO]{Share\LaTeX}
Matrices (/learn \fancyhead[RE,LO]{Guides and tutorials}
/Attribute_Value_Matrices) \fancyfoot[CE,CO]{\leftmark}
\fancyfoot[LE,RO]{\thepage}
Class �les
Understanding \begin{document}
packages and class
\chapter{Using different page styles}
�les (/learn
/Understanding_packages_and_class_�les)
Lorem ipsum dolor sit amet, consectetur
List of packages and adipiscing ...
class �les (/learn
/List_of_packages_and_class_�les)
Writing your own
package (/learn
/Writing_your_own_package)
Writing your own class
(/learn
/Writing_your_own_class)
Tips (/learn/Tips)

(/learn/File:HeadersFootersEx6.png)

8 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

The selectors that can be passed, inside brackets, to the


commands \fancyhead and \fancyfoot are:

E for even page


O for odd page
L for left side
C for centered
R for right side

For instance, \fancyhead[LE,RO]{Share\LaTeX} 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 \leftmark and


\thepage used in the previous example see the reference
guide.

  Open an example of the fancyhdr package in ShareLaTeX


(https://www.sharelatex.com/project/new/template?zipUrl=
/project/5343fd0124874b0852c13b98/download/zip&
templateName=CustomizedHeaderFooter&compiler=pd�atex)

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:

9 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

\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}

\renewcommand{\headrulewidth}{2pt}
\renewcommand{\footrulewidth}{1pt}

\begin{document}

\chapter{Using different page styles}

Lorem ipsum dolor sit amet, consectetur


adipiscing ...

(/learn/File:HeadersFootersEx7.png)

There are two additional lines in this example:

\renewcommand{\headrulewidth}{2pt}
This sets the header line thickness to 2pt.

\renewcommand{\footrulewidth}{1pt}

10 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

Sets the footer line thickness to 1pt.

  Open an example of the fancyhdr package in ShareLaTeX


(https://www.sharelatex.com/project/new/template?zipUrl=
/project/5343fd0124874b0852c13b98/download/zip&
templateName=CustomizedHeaderFooter&compiler=pd�atex)

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

\thepage

adds number of the current page.

\thechapter

adds number of the current chapter.

\thesection

adds number of the current section.

\chaptername

adds the word "Chapter" in English or its equivalent in the


current language.

\leftmark

adds name and number of the current top-level structure


(for example, Chapter for reports and books classes;
Section for articles ) in uppercase letters.

\rightmark

adds name and number of the current next to top-level


structure (Section for reports and books; Subsection for
articles) in uppercase letters.

Further reading
For more information see:

Page numbering (/learn/Page_numbering)

11 of 12 1/1/70, 5:09 AM
Headers and footers - ShareLaTeX, Online LaTeX ... https://www.sharelatex.com/learn/Headers_and_f...

Single sided and double sided documents (/learn


/Single_sided_and_double_sided_documents)
Page size and margins (/learn/Page_size_and_margins)
Footnotes (/learn/Footnotes)
Margin notes (/learn/Margin_notes)
Bold, italics and underlining (/learn
/Bold,_italics_and_underlining)
Font sizes, families, and styles (/learn
/Font_sizes,_families,_and_styles)
Management in a large project (/learn
/Management_in_a_large_project)
The fancyhdr package documentation (http://linorg.usp.br
/CTAN/macros/latex/contrib/fancyhdr/fancyhdr.pdf)
Page layout documentation (http://www.ntg.nl/maps/16
/29.pdf)

12 of 12 1/1/70, 5:09 AM

S-ar putea să vă placă și