0

I am writing a book with LyX Version 2.3.6.1 (+TexLive 2021) I have choosen as Document Class in Lyx book standard but I do not like the default page numbering bottom-centered so I use the possibility to customize the LaTex preamble inside Lyx ( --> Document --> Settings --> LaTex Preamble) by using the fancyhdr package. So I have edit in the LaTex Preamble windows inside Lyx the following code

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}

When I export the pdf, EVERY page number is printed ONLY (and ALWAYS) in the bottom Left If I change the last command in this way

\fancyfoot[RO,LE]{\thepage}

EVERY page number is always written only and always in the bottom right

I show you below the complete preamble which is export from Lyx to Latex

%% LyX 2.3.6.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[oneside,italian]{book}
\usepackage[LGR,T1]{fontenc}
\usepackage[latin9]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{textcomp}
\usepackage{url}
\usepackage{amsmath}
\PassOptionsToPackage{normalem}{ulem}
\usepackage{ulem}
\usepackage{subscript}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\DeclareRobustCommand{\greektext}{%
  \fontencoding{LGR}\selectfont\def\encodingdefault{LGR}}
\DeclareRobustCommand{\textgreek}[1]{\leavevmode{\greektext #1}}
\ProvideTextCommand{\~}{LGR}[1]{\char126#1}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\numberwithin{equation}{section}
\numberwithin{figure}{section}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%Custom settings LatTex Preamble to define page numbering 
%START
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{} % erase all the symbols from the foot page
\fancyfoot[RO,LE]{\thepage} %this should print right odd pages and left even pages 

% END

\makeatother

\usepackage{babel}
\begin{document}

....(here the document start)

Thanks in advance for helping!!

4
  • 3
    I think options RO and LE make only sense for twoside documents, while your document is set to oneside. I am surprised fancyhdr has not ignored them or does not warn you. If you set the document to twoside, does the code work? For oneside your settings should probably be simplified to \fancyfoot[R]{\thepage} etc.
    – Celdor
    Jan 10, 2022 at 1:27
  • 1
    Fancyhdr does give a warning. But many people don't even look at LaTeX warnings. I am thinking of adding an option to fancyhdr to make two-sided headers and footers available in a one-sided document, but I am not sure it is worth the effort, as you can as easily use the [twoside] document class option, and if you don't like the layout change it with geometry. Jan 10, 2022 at 8:44
  • @PietervanOostrum You are right. fancyhdr shows the warning. I never used TexLive which might not show logs but I doubt it. I checked with my IDE, which is Atom, latex, and language-latex and the warning from fancyhdr is right there.
    – Celdor
    Jan 10, 2022 at 10:11
  • Every TeX system generates a log file (<yourdocument>.log). It is always advised to look into it because it may have some warnings or errors in it. Sometimes it is full of annoying messages that may not be very interesting, and that can be a challenge to find the really useful information. Jan 10, 2022 at 10:28

1 Answer 1

1

I had exactly the same issue many times, see also the comments above.

Probably the problem is due to the initial line of your template:

\documentclass[oneside,italian]{book}

Instead, write this:

\documentclass[twoside,italian]{book}

I hope this may help you.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .