手动控制页眉和页码

手动控制页眉和页码

我正在写一份报告,如果我使用命令,\pagestyle{plain} 页码就会出现在底部,这样就很好了。

但是我还想让章节标题出现在左上角,这怎么可能呢?如果我删除\pagestyle{plain},那么标题会出现在左上角,但页码也会出现在右上角,而我想要的是它出现在底部!

\documentclass[letterpaper,11pt,oneside,final]{book}


%-----------------------------------------------------------------------------%
% Margins:
%-----------------------------------------------------------------------------%
\setlength{\marginparwidth}{0pt} % width of margin notes
\setlength{\marginparsep}{0pt} % width of space between body text and margin notes
\setlength{\evensidemargin}{0.125in} % Adds 1/8 in. to binding side of all 
\setlength{\oddsidemargin}{0.125in} % Adds 1/8 in. to the left of all pages
\setlength{\textwidth}{6.375in} % assuming US letter paper (8.5 in. x 11 in.) and 
\raggedbottom
\setlength{\parskip}{\medskipamount}

\renewcommand{\baselinestretch}{1.1} % this is the default line space setting

\let\origdoublepage\cleardoublepage
\newcommand{\clearemptydoublepage}{%
  \clearpage{\pagestyle{empty}\origdoublepage}}
\let\cleardoublepage\clearemptydoublepage


\usepackage[pdftex,letterpaper=true,pagebackref=true]{hyperref} % with basic options
\usepackage{hypcap}


\usepackage{grffile}
\usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{mathpazo}
\usepackage{stmaryrd}
\usepackage{rotating}
\usepackage{dsfont}


\hypersetup{pdfpagemode=UseNone}


%\fancyhf{}


\usepackage{fancyhdr}

\fancyhf{} % clear header and footer
\fancyhead[L]{\leftmark}
\fancyfoot[C]{\thepage}
\pagestyle{fancy}
\fancypagestyle{plain}{} % inherit the settings from fancy style


\begin{document}

snippet      

As any dedicated reader can clearly see, the Ideal of practical reason is a rep-
resentation of, as far as I know, the things in themselves; as I have shown else-
where, the phenomena should only be used as a canon for our understanding.
The paralogisms of practical reason are what rst give rise to the architectonic
of practical reason. As will easily be shown in the next section, reason would
thereby be made to contradict, in view of these considerations, the Ideal of prac-
tical reason, yet the manifold depends on the phenomena. Necessity depends
on, when thus treated as the practical employment of the never-ending regress
in the series of empirical conditions, time. Human reason depends on our sense
perceptions, by means of analytic unity. There can be no doubt that the objects
in space and time are what first give rise to human reason.

\section{Test 1}
As any dedicated reader can clearly see, the Ideal of practical reason is a rep-
resentation of, as far as I know, the things in themselves; as I have shown else-
where, the phenomena should only be used as a canon for our understanding.
The paralogisms of practical reason are what rst give rise to the architectonic
of practical reason. As will easily be shown in the next section, reason would
thereby be made to contradict, in view of these considerations, the Ideal of prac-
tical reason, yet the manifold depends on the phenomena. Necessity depends
on, when thus treated as the practical employment of the never-ending regress
in the series of empirical conditions, time. Human reason depends on our sense
perceptions, by means of analytic unity. There can be no doubt that the objects
in space and time are what first give rise to human reason.
\pagestyle{empty}

\bibliographystyle{alpha}


\nocite{*}
\hfill \today


\end{document}

答案1

plain这是使页面样式等于fancy页面样式的另一种方法

您必须使用\chapter,以便\leftmark定义。此外,您还使用了\pagestyle{empty}。在前面放置一个\clearpage\cleardoublepage如果使用twoside选项)。

\documentclass[letterpaper,11pt,oneside,final]{book}


%-----------------------------------------------------------------------------%
% Margins:
%-----------------------------------------------------------------------------%
\setlength{\marginparwidth}{0pt} % width of margin notes
\setlength{\marginparsep}{0pt} % width of space between body text and margin notes
\setlength{\evensidemargin}{0.125in} % Adds 1/8 in. to binding side of all
\setlength{\oddsidemargin}{0.125in} % Adds 1/8 in. to the left of all pages
\setlength{\textwidth}{6.375in} % assuming US letter paper (8.5 in. x 11 in.) and
\raggedbottom
\setlength{\parskip}{\medskipamount}

\renewcommand{\baselinestretch}{1.1} % this is the default line space setting

%\let\origdoublepage\cleardoublepage
%\newcommand{\clearemptydoublepage}{%
%  \clearpage{\pagestyle{empty}\origdoublepage}}
%\let\cleardoublepage\clearemptydoublepage


\usepackage[pdftex,letterpaper=true,pagebackref=true]{hyperref} % with basic options
\usepackage{hypcap}


\usepackage{grffile}
\usepackage{libertine}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{mathpazo}
\usepackage{stmaryrd}
\usepackage{rotating}
\usepackage{dsfont}


%\hypersetup{pdfpagemode=UseNone}


\usepackage{fancyhdr}

\fancyhf{} % clear header and footer
\fancyhead[L]{\leftmark}
\fancyfoot[C]{\thepage}



\makeatletter
\let\ps@plain\ps@fancy % plain style = fancy style
\makeatother

\pagestyle{fancy}

\begin{document}

\chapter{One}

As any dedicated reader can clearly see, the Ideal of practical reason is a rep-
resentation of, as far as I know, the things in themselves; as I have shown else-
where, the phenomena should only be used as a canon for our understanding.
The paralogisms of practical reason are what rst give rise to the architectonic
of practical reason. As will easily be shown in the next section, reason would
thereby be made to contradict, in view of these considerations, the Ideal of prac-
tical reason, yet the manifold depends on the phenomena. Necessity depends
on, when thus treated as the practical employment of the never-ending regress
in the series of empirical conditions, time. Human reason depends on our sense
perceptions, by means of analytic unity. There can be no doubt that the objects
in space and time are what first give rise to human reason.


\section{Test 1}
As any dedicated reader can clearly see, the Ideal of practical reason is a rep-
resentation of, as far as I know, the things in themselves; as I have shown else-
where, the phenomena should only be used as a canon for our understanding.
The paralogisms of practical reason are what rst give rise to the architectonic
of practical reason. As will easily be shown in the next section, reason would
thereby be made to contradict, in view of these considerations, the Ideal of prac-
tical reason, yet the manifold depends on the phenomena. Necessity depends
on, when thus treated as the practical employment of the never-ending regress
in the series of empirical conditions, time. Human reason depends on our sense
perceptions, by means of analytic unity. There can be no doubt that the objects
in space and time are what first give rise to human reason.

As any dedicated reader can clearly see, the Ideal of practical reason is a rep-
resentation of, as far as I know, the things in themselves; as I have shown else-
where, the phenomena should only be used as a canon for our understanding.
The paralogisms of practical reason are what rst give rise to the architectonic
of practical reason. As will easily be shown in the next section, reason would
thereby be made to contradict, in view of these considerations, the Ideal of prac-
tical reason, yet the manifold depends on the phenomena. Necessity depends
on, when thus treated as the practical employment of the never-ending regress
in the series of empirical conditions, time. Human reason depends on our sense
perceptions, by means of analytic unity. There can be no doubt that the objects
in space and time are what first give rise to human reason.

\clearpage
\pagestyle{empty}

\bibliographystyle{alpha}


\nocite{*}
\hfill \today


\end{document}

在此处输入图片描述

稍微不相关的是,您可以考虑使用geometry包来更改页面布局。

答案2

如果我理解正确的话,您希望所有页面(包括章节的第一页)都有相同的行为。

您希望将章节标题放在页眉的左侧,将页码放在页脚的中央。

下面的代码正是这样做的:

\documentclass{report}
\usepackage{fancyhdr}

\fancyhf{} % clear header and footer
\fancyhead[L]{\leftmark}
\fancyfoot[C]{\thepage}

\pagestyle{fancy}

\fancypagestyle{plain}{} % inherit the settings from fancy style

\usepackage{kantlipsum} % only for the example

\begin{document}
\chapter{Test}
\kant[1]
\section{Test}
\kant[2-7]
\end{document} 

在此处输入图片描述

答案3

您尝试过使用该fancyhdr包吗?我刚刚实现了它来做类似的事情。语法非常简单,您基本上可以自定义页面布局来获得您想要的内容。

下面几行也许能让你接近?

\documentclass[12pt, a4paper, oneside, fleqn]{report}

\headheight 28pt
\headsep 24pt

\usepackage{lmodern}       % gives bold italic font
\usepackage{lipsum}
%Sectioning and headings
%------------------------
\usepackage{fancyhdr}

 \begin{document}

\pagestyle{fancy}
\lhead{\leftmark}
\chead{}
\rhead{}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

\chapter{A chapter}
\lipsum


\end{document}

相关内容