I posted this in another thread and was told to open a new one. Here we go:

How do I add header and footer in Lyx 2.2.2

I had this preamble and it worked.

\ihead{4776020 Stephan Goldenberg}
\ohead{01801 WS 2016/2017 EA 3}

But there was an update for Lyx which obviously broke it. How do I get header and footer back ?

Edit: I don't know Latex, though. Noobish words please :)

Edit2: So I did what the user guide says but still no header & footer. I've deleted the preamble and the errors went away but still no header & footer.

enter image description here

I don't get it to work, Lyx seems broken.

I've started a new blank document. Page style is set to fancy, custom header/footerlines is added in the modules section, preamble is empty. But still no header and no footer. Obviously I'm too numb for this, I give up.

enter image description here

% Preview source code

%% LyX 2.2.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.



\lhead{4776020 Stephan Goldenberg}

\rhead{01801 WS 2016/2017 EA 3}



Aufgabe 3.1:

  • 1
    Take a look at Help > User Guide at Section "6.11 Customized Page Headers and Footers" – scottkosty Jan 8 '17 at 20:11
  • Thanks for answering but that did not help. I did what the user guide said and now I'm getting errors and the page number at the bottom has disappeared too. LaTeX Error: Command \chead already defined. LaTeX Error: Command \cfoot already defined. These are not defined by me. Like I said, this is not for mere mortals. I had to turn in, thank god, I could produce something using LibreOffice. – Stephan Goldenberg Jan 9 '17 at 11:21
  • Maybe LyX already loads either fancyhdr or scrlayer-scrpage. In this case you cannot use scrpage2 and you don't need to use it. Simply use the package LyX already loads. BTW: scrpage2 is obsolete. The successor is scrlayer-scrpage. – Schweinebacke Jan 9 '17 at 11:49
  • Schweinebacke ist schön :) Forgot to mention that I've removed my preamble before this but still no worky. – Stephan Goldenberg Jan 9 '17 at 13:17
  • Strange, if I do exactly what you say at the end there it works fine here. No errors or warnings? Can you open the Source pane (View->Source Pane), choose Complete source in the drop-down menu on the right (probably says Current paragraph by default), and copy-paste everything from \documentclass to \end{document} into your question? – Torbjørn T. Jan 10 '17 at 16:55

There are a couple of things that cause your problems here:

  1. It seems that the amsart class, that you were using, sets a different page style for the first page only. I'm sure if you add some text on the second page, you'll see the header and footer appear.

    To make the first page have the fancy pagestyle as well, place the cursor at the start of the document, hit Ctrl + L and type \thispagestyle{fancy} in the box that appears.

    In the standard article class this is not necessary.

  2. If you type \today directly in LyX, LyX assumes that you actually want to display a backslash followed by today in the PDF, so it inserts \textbackslash{}today. To use LaTeX code in the document, you need to add a TeX Code inset, as mentioned above, with Ctrl + L (or insert -> TeX Code).

  3. If the header and footer of the fancy pagestyle is not cleared, the default settings are kept, and they include a pagenumber in the center field of the footer. To remove that, add the Center footer in the same way as the right and left footer, and keep it empty.

Here is an example .lyx file which uses amsart, but with the custom header and footer on all pages:

#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\save_transient_properties true
\origin unavailable
\textclass amsart
\use_default_options true
\maintain_unincluded_children false
\language english
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\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 default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\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 1
\index Index
\shortcut idx
\color #008000
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle fancy
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false


\begin_layout Left Header
4776020 Stephan Goldenberg

\begin_layout Right Header
01801 WS 2016/2017 EA 3

\begin_layout Left Footer
\begin_inset ERT
status open

\begin_layout Plain Layout




\begin_layout Right Footer
\begin_inset ERT
status open

\begin_layout Plain Layout




\begin_layout Center Footer


\begin_layout Standard
\begin_inset ERT
status open

\begin_layout Plain Layout




\begin_layout Standard
Some text

\begin_layout Standard
\begin_inset Newpage newpage


\begin_layout Standard
Next page


And a screenshot of the LyX GUI and output:

enter image description here

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.