如果之前有人问过这个问题,我很抱歉,但是我还找不到任何答案。
我目前正在用 LATEX 撰写我的学士论文,但在页码编排方面遇到了问题。
我在一篇文章中使用 fancyhdr 包。前几项,如致谢和目录等,应该在页脚的左侧/右侧用罗马数字编号,就像在书中一样。我能够获得罗马数字,但它保持居中。当我删除整个页脚时,阿拉伯页码仍然留在中间。
\documentclass[a4paper,12pt,twoside]{article}
\usepackage[super,square,sort&compress]{natbib} %Zitierstil
\setcitestyle{nature} %Literaturstil
\bibliographystyle{unsrtnat} %Literatur sortiert nach Auftreten im Text
\usepackage{hyperref}
\usepackage[usenames, dvipsnames]{color}
\usepackage{ghsystem}
\usepackage[ngerman]{babel}
\usepackage{subfiles}
\usepackage{chemmacros}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage[version=4]{mhchem}
\usepackage{pdfpages}
\usepackage[utf8x]{inputenc}
\usepackage[labelfont={color=text,bf}]{caption}
\usepackage{cancel, caption, mathtools, subcaption, amsthm}
\usepackage[margin={0.10\paperwidth,0.1\paperheight}, heightrounded, bindingoffset=1cm]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{array}
\usepackage{microtype}
\usepackage{booktabs}
\usepackage{icomma}
\usepackage{bibgerm}
\usepackage{titling}
\usepackage[onehalfspacing]{setspace}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{float}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{multirow}
\usepackage[header]{appendix}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------optionale Packages-------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\numberwithin{equation}{section}
\usepackage{lipsum} %Blindtext
\usepackage{blindtext} %Blindtext
\graphicspath{{images}{../images}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%---------Zeilenabstand---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\baselinestretch}{1.5}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%--------2. Listenebene---------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\labelitemii}{-}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%------------Farben-------------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\definecolor{text}{RGB}{0,0,0}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------Schriftart-----------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\renewcommand{\familydefault}{\sfdefault}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------Titelseite----------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\thispagestyle{empty}
\input{Sections/titlepage}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----Fußzeile & Nummerierung----%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\pagenumbering{roman} %Römische Seitenzahlen
\setcounter{page}{1} %Start der Nummerierung
\fancyfoot[C]{}
\fancyfoot[OR,EL]{\thepage} %O=odd, E=even
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%-----------Danksagung----------%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\input{Sections/acknowledgement}
后来我对论文主体也做了同样的事情,效果很好。
如果有人能回答我的话我就太好了:)谢谢!
编辑:
我找到了一个解决方案,使页码在目录中居中。这是因为命令 \tableofcontents 会自动重置为普通页面样式。您必须重新定义普通页面样式:
\fancypagestyle{plain}{
\fancyhf{}
\fancyfoot[OR]{\thepage}
\fancyfoot[EL]{\thepage}
\renewcommand{\headrulewidth}{0pt}
}
结合其他答案,我终于搞定了!感谢大家的帮助!
答案1
问题是你没有将 改为pagestyle
fancy。试试这个
\documentclass[a4paper,12pt,twoside]{article}
\usepackage{fancyhdr}
\usepackage{lipsum}
\begin{document}
\lipsum[6-10]
\clearpage
\newpage
\pagestyle{fancy} % this is what you miss
\pagenumbering{roman}
% \setcounter{page}{1} % this is not needed as the \pagenumbering{roman} resets the page counter
\fancyhf{} % to clear the header and the footer simultaneously
\fancyfoot[OR,EL]{\thepage}
\renewcommand{\headrulewidth}{0pt} % to remove the rules
\renewcommand{\footrulewidth}{0pt} % to remove the rules
\lipsum[1-5]
\end{document}
答案2
对于使用它的人来说,使用配套包titlesec
重新定义更容易(也可以单独使用):plainstyle
titleps
\documentclass[a4paper,12pt,twoside]{article}
\usepackage{titleps}
\usepackage{lipsum}
\renewpagestyle{plain}{%
\sethead{}{}{}
\setfoot[\thepage][][]{}{}{\thepage}
}%
\begin{document}
\lipsum[6-10]
\clearpage
\pagenumbering{roman}
\pagestyle{plain}
\lipsum
\end{document}