我正在用 LyX 2.3.6.1 版 (+TexLive 2021) 写一本书,我已选择 Lyx 书籍标准中的文档类,但我不喜欢默认的底部居中页码,因此我使用 fancyhdr 包在 Lyx 中自定义 LaTex 序言(--> 文档 --> 设置 --> LaTex 序言)。因此,我在 Lyx 中的 LaTex 序言窗口中编辑了以下代码
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot{}
\fancyfoot[LE,RO]{\thepage}
当我导出 pdf 时,如果我以这种方式更改最后一个命令,则每个页码仅(并且始终)打印在左下角
\fancyfoot[RO,LE]{\thepage}
每一个页码都是只写在右下角
下面我向您展示了从 Lyx 导出到 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}
....(文档从这里开始)
提前感谢您的帮助!!
答案1
我多次遇到过完全相同的问题,另请参见上面的评论。
该问题可能出在您的模板的初始行上:
\documentclass[oneside,italian]{book}
相反,应该这样写:
\documentclass[twoside,italian]{book}
我希望这对你有帮助。