You are on page 1of 16
sert202018 Headers and footers - Ovetleat, Editor de LaTeX online Q Search help library... Headers and footers IS TEX 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. Contents * 1 Introduction + 2Standard page styles + 3Setting page style for current page only * 4Style customization in single-sided documents + 5 Style customization in double-sided documents + 6 Decorative lines on header and footer + 7 Reference guide + 8 Further reading 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: hitpsses.overleat.comlearnatex/Headers_ard footers ae ser1212018 Headers and footers - Ovetleat, Editor de LaTeX online \documentclass[adpaper,,12pt,, twoside] {book} \usepackage[english]{babel} \usepackage[ut#8]{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/lence betweenthis text and some nonsense like \Huardest gefburn"? Kjift { not at all!... \end{document} 21 New section Chapter 2 Sample Chapter (/learn/File:HeadersFootersEx1.png) ‘The command \pagestyle{headings} sets the page style called headingsto the current document. You can see more page styles in the next section hitpsses overeat comearnatexHeaders_and footers ane ro18 Nears an sts - Ove, dor de LaTeX onne @ Open an example in ShareLaTeX (https://www.sharelatex.com/project/new/template? zipUrl=/project/534173dadd7cb62b32b6f702/download/zip&templateName=Standard_head ers_footers&compiler=pdflatex) Standard page styles The standard page styles are invoked in IATEX by means of the command \pagestyle{''style''} \pagestyle{myheadings} 4 2.1 New section Hello, kere is some text without a meaning, This text should show what a printed text will look Like at this place. If you read this test, you will gst no information, Really? Is there no information? Ik there a difference between sume nonsense like “Huardest sefburs"? Kift ~ mot at alll A (/learn/File:HeadersFootersEx2.png) this test The myheadings pagestyle displays the page number on top of the page in the outer corner. There are other three page styles: + empty: Both the header and footer are cleared (blank) in this page style. + plain: Thisis the default style. The header is empty and the footer contains page numbers in the centre. + myheadings: 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 hitpsses.overleat.comlearnatex/Headers_ard footers ane sert202018 Headers and footers - Ovetleat, Editor de LaTeX online of each chapter, where the footer contains centred page number while the header is blank. @ Open an example in ShareLaTeX (https://www.sharelatex.com/project/new/template? zipUrl=/project/534173dadd7cb62b32b6f702/download/zipS&templateName=Standard_head ers_footers&compiler=pdflatex) 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} hitpsses.overleat.comlearnatex/Headers_ard footers ane sert202018 Headers and footers - Ovetleat, Editor de LaTeX online Chapter 2 Sample Chapter (learn/File:HeadersFootersEx3.png) Of course, you can replace empty for any of the styles mentioned in the previous section Open an example in ShareLaTeX (https://www.sharelatex.com/project/new/template? zipUrl=/project/534173dadd7cb62b32b6f702/download/zipS&templateName=Standard_head ers footersécompiler=pdflatex) Style customization in single-sided documents Styles can be modified beyond the standard layouts by means of fancyhdr. Below is an example. hitpsses.overleat.comlearnatex/Headers_ard footers ene sert202018 Headers and footers - Ovetleat, Editor de LaTeX online \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 diJlence between this ... \end{document} hitpsses.overleat.comlearnatex/Headers_ard footers ene ser1212018 Headers and footers - Ovetleat, Editor de LaTeX online Guides and torts Shore TEX 1 First Section Hello, bere ts some text without m meaning, ‘This text soll shows what printed wst will Took Uke at this place. IF jou ead this txt, you will yet no Florio: Re 9? Ie there om text and some nonsense ike“ (est Bao (hi sive you ifort ‘written and an imgreeson of the look. hs text shoukd comin all eters of {ee alphatot and H should be writen in ofthe orginal hngunge. "The br no toed for special content, but the lengths of words should int the lage Hello, hor icone text without a meaning. ‘This text chould chow what a printed txt will ook like at this place. IP you sead this text, you wll get 0 formation. Telly? Iethewe no information? Is there ndiference between thie test and somo nonsense ike “Huardost gofburi"? Kjift not at all! © blind (ot Eke this give you iformation about te alee fot, how the letteas are written and an impression ofthe lke This text shold conta all eters of {he alphabet aud ft alould be writen in of the orginal binguage. ‘The fs wo ned fhe special content, atthe length of words shoud match the langrnge cemation? Is Ure ilrenee between dest gefburn"? Kit — not at al A blind bout the let font, uw the eters are (/learn/File:HeadersFootersEx4.png) To customize the footer and header in your document first import the package fancyhdr with \usepackage{fancyhdr} After that, the "fancy" style is set by \pagestyle{ fancy}. The command \fancyhf{} 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. \rhead{Share\LaTex} Prints the text included inside the braces on the right side of the header. \lhead{Guides and tutorials} Prints the text set inside the braces on the left side of the header. \chead{ } Similar to the previous commands, in this case the text is centred on the header. hitpsses overeat comearnatexHeaders_and footers me rerareo18 Headers and footers - Overs, Edtor de LaTeX one \rfoot{Page \thepage} Prints the word "Page" and next the page number which is automatically set by \thepage on the right side of the footer. See the reference guide for alist of commands that automatically generate content (Section numbers, chapters and so on). \lfoot{ } This prints the parameter passed inside the braces on the left side of the footer. \cfoot{ } Similar to the previous two commands, prints its parameter on the centre of the footer. Open an example of the fancyhdr package in ShareLaTeX (https://wwwsharelatex.com/project/new/template? zipUrl=/project/53440a3824874b0852c13d61/download/zipS&templateName=OneSidedHed erFooterScompiler=pdflatex) Style customization in double-sided documents 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 \fancyhead and \fancyfoot with several selectors passed as parameters. Let's see: \documentclass[a4paper, 12pt, twoside] {book} \usepackage[ut#8]{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 ... hitpsses.overleat.comlearnatex/Headers_ard footers ane sert202018 Headers and footers - Ovetleat, Editor de LaTeX online 21 New sctlow (/learn/File:HeadersFootersExé.png) 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 \1eftmark 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=CustomizedHe aderFooter&compiler=pdflatex) hitpsses overeat comearnatexHeaders_and footers one sert202018 Headers and footers - Ovetleat, Editor de LaTeX online 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 Opt thickness and hence is not visible. It's easy to change that: \documentclass[a4paper, 12pt, twoside] {book} \usepackage[ut8]{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 ... hitpsses.overleat.comlearnatex/Headers_ard footers sone sert202018 Headers and footers - Ovetleat, Editor de LaTeX online ShareDSTEX Guides and tutorials 2.1 New section Hollo, here is some text without a meaning, This text should show what a printed text will look like at this place. If you read this text. you will get no information. Really? Is there no information? Is there a difference hetween this text and some nonsense like “Huardest gefhurn”? Kjift — not at alll A Dlind text like this gives you information about the selected font, how the letters are written and an impression of the look. This text should contain all otters of the alphabet and it should be written in of the original language, There is no need for special content, but the length of words should match the language. Hello, here is some text without a meaning. This text should show what a printed text will look like at this place, If you wad this text, you will get no information. Really? Is there no information? Is there a diflerence between 4 CHAPTER 2. SAMPLE CHAPTER (/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} Sets the footer line thickness to Apt. © Open an example of the fancyhdr package in ShareLaTeX (https://wwwsharelatex.com/project/new/template? zipUrl=/project/5343fd0124874b0852c13b98/download/zipS&templateName=CustomizedHe aderFooter&compiler=pdflatex) Reference guide The following commands can be used in the headers and footers to add custom information + \thepage hitpsses.overleat.comlearnatex/Headers_ard footers s6 sert202018 Headers and footers - Ovetleat, Editor de LaTeX online 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 reportsand books; Subsection for articles) in uppercase letters. Further reading For more information see: Page numbering (/learn/Page_numbering) ‘+ 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 (earn/Bold, italics_and_underlining) + Fontsizes, 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) Documentation Home (/learn/Main Page) Learn LaTeX in 30 minutes (/learn/Learn_LaTeX in_30_minutes) hitpsses.overleat.comlearnlatex/Headers_ard footers vane sert202018 Headers and footers - Ovetleat, Editor de LaTeX online Overleaf guides Creating a document in Overleaf (/learn/Kb/Creating_a_document_in_Overleaf) Uploading a project (/learn/Kb/Uploading_a_project) Copying a project /learn/Kb/Copying_a_project) Creating a project from a template (/learn/Kb/Creating_a_project,from_a_template) Including images in Overleaf (/learn/Kb/Including_ images. in ShareLaTeX) Exporting your work from Overleaf (/learn/Kb/Exporting_your_work from_ShareLaTeX) Working offline in Overleaf (/learn/Kb/Working_Offline_in_Overleaf_v2) Using Track Changes in Overleaf (/learn/Kb/Track_Changes_in_Overleaf_v2) Using bibliographies in Overleaf (/learn/Kb/Using_bibliographies_in_ShareLaTeX) Sharing your work with others (/learn/Kb/Sharing_your_work_with_others) Debugging Compilation timeout errors (/learn/Kb/Debugging Compilation timeout_errors) How-to guides (/learn/Kb/Knowledge Base) LaTeX Basics Creating your first LaTeX document (/learn/Creating_a_document in_LaTeX) Choosing a LaTex Compiler (/learn/Choosing_a_LaTeX Compiler) Paragraphs and new lines (learn/Paragraphs_and_new_lines) Bold, italics and underlining (/learn/Bold, italics_and_underlining) Lists /learn/Lists) Errors (Mlearn/Errors) Mathematics Mathematical expressions (/learn/Mathematical_expressions) Subscripts and superscripts (/learn/Subscripts_and_superscripts) Brackets and Parentheses (/learn/Brackets_and_Parentheses) Fractions and Binomials (/learn/Fractions_and_Binomials) Aligning Equations (/learn/Aligning_equations) Operators (/learn/Operators) Spacing in math mode (/learn/Spacing_in_math_mode) Integrals, sums and limits (/learn/Integrals,_sums_and_limits) Display style in math mode (/learn/Display_style_in_math_mode) List of Greek letters and math symbols (/learn/List_of_Greek_letters_and_math_symbols) Mathematical fonts (/learn/Mathematical_fonts) Figures and tables hitpsses.overleat.comlearnatex/Headers_ard footers sane serr2n018 Headers and footers -Oveteat, Edior de LaTeX online Inserting Images (/learn/Inserting_ Images) Tables (/learn/Tables) Positioning Images and Tables (/learn/Positioning_images_and_tables) Lists of Tables and Figures (/learn/Lists_of_tables_and_figures) Drawing Diagrams Directly in LaTeX (/learn/Picture_environment) TikZ package (/learn/TikZ_package) References and Citations Bibliography management in LaTex (/learn/Bibliography_management.in_LaTeX) Bibliography management with biblatex (/learn/Bibliography_management_in_LaTeX) Biblatex bibliography styles (/learn/Biblatex_bibliography_styles) Biblatex tion styles (/learn/Biblatex_citation styles) Bibliography management with natbib (/learn/Bibliography_management_with_natbib) Natbib bibliography styles (/learn/Natbib_bibliography_styles) Natbib citation styles (/learn/Natbib citation styles) Bibliography management with bibtex (/learn/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 (Mlearn/Arabic) Chinese (/learn/Chinese) French (/learn/French) German (/learn/German) Greek (/learn/Greek) Italian (learnv|talian) 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) hitpsses.overleat.comlearnatex/Headers_ard footers sane serr2n018 Headers and footers -Oveteat, Edior de LaTeX online Cross referencing sections and equations (/learn/Cross_referencing_sections_and_equations) Indices (/learn/Indices) Glossaries (/learn/Glossaries) Nomenclatures (/learn/Nomenclatures) Management in a large project (/learn/Management_in_a_large_project) Multi-file LaTeX projects (/learn/Multi-file LaTeX projects) Hyperlinks (/learn/Hyperlinks) Formatting Lengths in LATgX (/learn/Lengths in_LaTeX) Headers and footers (/learn/Headers_and footers) Page numbering (/learn/Page_numbering) Paragraph formatting (/learn/Paragraph formatting) Line breaks and blank spaces (Nlearn/Line_breaks_and_blank spaces) Text alignment (/learn/Text_alignment) Page size and margins (/learn/Page_size_and_margins) le -d and double sided documents (/learn/Single_sided_and_double_sided_documents) Multiple columns (/learn/Multiple_columns) Counters (/learn/Counters) Code listing (/learn/Code isting) Code Highlighting with minted (/learn/Code Highlighting with_minted) Using colours in LaTeX (Mlearn/Using_colours_in_ LaTeX) Footnotes (/learn/Footnotes) Margin notes (/learn/Margin_notes) Fonts Font sizes, families, and styles (/learn/Font_sizes, families, and_styles) Font typefaces (/learn/Font_typefaces) ‘Supporting modern fonts with XsLATiX (/learn/XeLaTeX) Presentations Beamer (/learn/Beamer) Powerdot (/learn/Powerdot) Posters (/learn/Posters) Commands hitpsses.overleat.comlearnatex/Headers_ard footers r6n6 sert202018 Headers and footers - Ovetleat, Editor de LaTeX online ‘Commands (/learn/Commands) Environments (/learn/Environments) Field specific Theorems and proofs (/learn/Theorems_and_proofs) Chemistry formulae (learn/Chemistry_ formulae) Feynman diagrams (/learn/Feynman_diagrams) Molecular orbital diagrams (/learn/Molecular_orbital.diagrams) Chess notation (/learn/Chess notation) Knitting patterns /learn/Knitting patterns) CircuiTikz package (learn/CircuiTikz_package) Pefplots package (/learn/Pefplots package) Typing exams in LaTeX (/learn/Typing_exams.in_LaTeX) Knitr V/learn/Knitr) Attribute Value Matrices (/learn/Attribute Value Matrices) Class files Understanding packages and class files (/learn/Understanding_packages_and_class_files) List of packages and class files (/learn/List_of_packages_and_class_files) Writing your own package (/learn/Writing_ your_own_package) Writing your own class (/learn/Writing_your_own_class) Tips (learn/Tips) © 2018 Overleaf Privacy and Terms (https://www.overleaf-com/legal) Seguridad (https://www.overleaf.com/legal#Security) Contactanos (https:/www.overleaf.com/contact) Quiénes somos (https:/www.overleaf.com/about) Blog (https://www.overleaf.com/blog) QO ihttps:/twitter.comvoverleaf) [9 (https://www.facebook.com/overleaf.editor) (https://plus.google.com/+WritelatexOnline) Gi) (https: hitpsses.overleat.comlearnatex/Headers_ard footers /wwwulinkedin.com/company/writelatex-limited) rene

You might also like