Why can't I find Header & Footer when I open an new file in LyX?
[Tex/LaTex] LYX- Adding Headers
header-footerlyx
Related Solutions
I did something similar recently. I didn't define the headers and footers in the preamble, but instead went to Document settings > Modules and enabled "Custom Header/Footerlines". This adds 6 new layouts in the drowdown menu (see picture).
With this and a few TeX boxes, you can achieve what you want. I'm not sure how to best show it here - maybe just copy this code to an editor, save it as a .lyx
file, and open it in LyX. I tried to explain everything in there:
#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass extarticle
\begin_preamble
\pagestyle{fancy}
\end_preamble
\use_default_options false
\begin_modules
customHeadersFooters
\end_modules
\maintain_unincluded_children false
\language american
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "times" "Times New Roman"
\font_sans "helvet" "Arial"
\font_typewriter "courier" "Courier New"
\font_math "auto" "default"
\font_default_family default
\use_non_tex_fonts true
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize 12
\spacing onehalf
\use_hyperref true
\pdf_title "Blah"
\pdf_author "Ginchen"
\pdf_keywords "blah, blah, blah"
\pdf_bookmarks true
\pdf_bookmarksnumbered true
\pdf_bookmarksopen true
\pdf_bookmarksopenlevel 2
\pdf_breaklinks false
\pdf_pdfborder false
\pdf_colorlinks true
\pdf_backref page
\pdf_pdfusetitle false
\pdf_quoted_options "linkcolor=black, citecolor=black, urlcolor=blue, filecolor=blue, pdfpagelayout=OneColumn, pdfnewwindow=true, pdfstartview=XYZ, plainpages=false"
\papersize a4paper
\use_geometry true
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 0
\use_package esint 0
\use_package mathdots 1
\use_package mathtools 0
\use_package mhchem 1
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\index Stichwortverzeichnis
\shortcut idx
\color #008000
\end_index
\leftmargin 2.5cm
\topmargin 2.5cm
\rightmargin 2.5cm
\bottommargin 2cm
\secnumdepth 3
\tocdepth 3
\paragraph_separation skip
\defskip bigskip
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle fancy
\bullet 1 0 9 -1
\bullet 2 1 35 -1
\bullet 3 1 29 -1
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Center Footer
This is my footer that appears on all pages starting from page 1!
\end_layout
\begin_layout Standard
\begin_inset Note Note
status open
\begin_layout Plain Layout
The following headers are set to empty, because otherwise the table of contents
gets an ugly
\begin_inset Quotes eld
\end_inset
CONTENTS - CONTENTS
\begin_inset Quotes erd
\end_inset
header.
\end_layout
\end_inset
\end_layout
\begin_layout Left Header
\end_layout
\begin_layout Center Header
\end_layout
\begin_layout Right Header
\end_layout
\begin_layout Title
Title
\end_layout
\begin_layout Author
Author
\end_layout
\begin_layout Standard
\begin_inset Note Note
status open
\begin_layout Plain Layout
The title page usually uses the plain layout, which includes a page number
in the footer instead of the footer defined above.
So we set the page style to fancy for this page.
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
thispagestyle{fancy}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Note Note
status open
\begin_layout Plain Layout
Although the header is empty, the line beneath it will still display.
\begin_inset Newline newline
\end_inset
So we remove it by making it 0pt high.
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
renewcommand{
\backslash
headrulewidth}{0pt}
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Abstract
blah blah blah
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Standard
\begin_inset CommandInset toc
LatexCommand tableofcontents
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Newpage newpage
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Note Note
status open
\begin_layout Plain Layout
The following headers will be shown starting from this point.
\end_layout
\end_inset
\end_layout
\begin_layout Left Header
\noindent
This is the header that will only begin to appear after all the front matter
\end_layout
\begin_layout Right Header
Page
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
thepage
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset Note Note
status open
\begin_layout Plain Layout
If you want the line beneath the header back, you can set it back to 1pt:
\end_layout
\end_inset
\end_layout
\begin_layout Standard
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
renewcommand{
\backslash
headrulewidth}{1pt}
\end_layout
\end_inset
\end_layout
\begin_layout Part
Once upon a time...
\end_layout
\begin_layout Standard
...
there was a question in the TeX StackExchange, and the princess of LyX
wrote a meaningless text just for the sake of an example.
\end_layout
\end_body
\end_document
Best Answer
Add the Document > Settings... > Modules > Custom Header/Footerlines module:
This will give you access to provide header/footer specifications:
Also, you can add the headers/footer manually using Document > Settings... > LaTeX Preamble and adding the
fancyhdr
package: