# How to insert uneven page number in Lyx thesis / book template?

Writing a thesis with Lyx, I had only page number on even pages. Here is where this seems to be configured in the page

\lfoot[\thepage]{}
\cfoot{}
\rfoot[]{\thepage}


In the master document I fixed this by changing the third line to \rfoot[]{\thepage}̀.

But in another document I don't manage to change page numbering on unevenpages. I would like to number uneven pages on the right side. This answer explains how to insert Custom Header/Footerines, but it doesn't explain how to add the Even header elements I see in the screenshot below of the thesis template. How to insert these red on grey background elements I see in the screenshot below?

I posted an example file as a gist testpagenumber.lyx (and also the tex version testpagenumber.tex). You can see that the compiled PDF document has no page number on page 3.

%% LyX 2.1.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[12pt,a4paper,british]{scrbook}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[authoryear]{natbib}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth

\makeatother

\usepackage{babel}
\begin{document}

\lfoot[\thepage]{}

\cfoot{}

\rfoot[\thepage]{}

\chapter{testant}

bla

\pagebreak{}

bla

bla

\pagebreak{}

bla

bla

\pagebreak{}

bla
\end{document}

• A minimal working example would be great. I am not sure if your document is twosided. I am not sure if you are using fancyhdr since your commands suggest otherwise. The setup right now is really strange, to be honest. Jan 15, 2017 at 14:10
• I posted an example here gist.github.com/paul4forest/7671132f19412a0cac2f6ecb99955add, it's not really minimal because I kept all of the formatting of my original document. Jan 15, 2017 at 14:22
• Now removed most of the formatting from the gist example. The issue is the page number missing on page 3. Jan 15, 2017 at 14:51
• If you now convert that to pdflatex and post it within the question, even more people will be able to help you. Jan 15, 2017 at 14:54

You might want the following, but i am not sure.

%% LyX 2.1.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
%% JB edited the LyX code
\documentclass[12pt,a4paper,british]{scrbook}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[authoryear]{natbib}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\pdfpageheight\paperheight
\pdfpagewidth\paperwidth

\makeatother

\usepackage{babel}
\usepackage{scrlayer-scrpage}
\renewcommand{\chaptermarkformat}{\chapapp\ \thechapter\autodot\enskip}
\ofoot{\pagemark}
\usepackage{blindtext}
\begin{document}

\blinddocument
\end{document}


The solution is to insert \thepage after the square brackets in the curly braces. Change from

\lfoot[\thepage]{}
\cfoot{}
\rfoot[\thepage]{}


to

\lfoot[\thepage]{}
\cfoot{}
\rfoot[]{\thepage}


Or in Lyx to change from : to :

This is a strange behaviour. I wonder why it is not called "uneven header" in Lyx.

• I am a bit confused, because i don't see why there are brackets in there. Or why you are doing it the way you are doing. That stuff should best go to the preamble. Or be done within the LyX interface (don't know if LyX supports KOMA-packages over the interface). Jan 15, 2017 at 15:26
• Yes I'm confused too and this does not seem to be documented on the Lyx wiki. Jan 15, 2017 at 15:35