fancyhdr 页面装饰和页码

fancyhdr 页面装饰和页码

您好,这里有多个装饰页面的示例。大多数示例适用于单页,不需要编号。

当我尝试为每一页制作时。它不起作用,或者我的页码有问题。请参见下面的示例

\documentclass[a4paper]{article}
\usepackage{fancyhdr}
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage[english]{babel}
\usepackage{blindtext}
\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\newcommand{\wbc}[3]{\vspace*{#1}\begin{center}
    \wb{#2}{#2}#3\end{center}\vspace*{#1}}

\fancyhf{}
\lhead{\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(-36,5){\makebox(0,0)[br]{\wb{36bp}{36bp}A}}
    \end{picture}}
\rhead{\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(29,5){\makebox(0,0)[bl]{\wb{36bp}{36bp}B}}
    \end{picture}}
\lfoot{\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(-36,-3){\makebox(0,0)[tr]{\wb{36bp}{36bp}C}}
    \end{picture}}
\rfoot{\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(29,-3){\makebox(0,0)[tl]{\wb{36bp}{36bp}D}}
    \end{picture}}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}

\begin{document}
 \blindtext[10]
  \wbc{2ex}{6}{IJLKIJLKIJLKIJLKIJ}

 \blindtext[3]

  \wbc{1ex}{8}{pq}


\end{document}

运行正常,但没有页码,因为页眉/页脚被重新定义

这是另一个例子

% $Id: sample1.tex,v 1.3 2002/09/13 06:34:25 loreti Exp $

\documentclass[10pt,twoside]{book}
\usepackage{fancyhdr,geometry,keyval,ifthen,makeidx,multicol,mparhack,poemscol}
\usepackage{times}
\geometry{textwidth=4in,textheight=6.75in}
\makeverselinenumbers
\global\includeaccidentalstrue
\global\includetypescriptstrue
\global\redundantemendationsfalse
\stanzaatbottom{*}
\nostanzaatbottom{\relax}
%\reversemarginpar
\usepackage{fancyhdr}

\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
%\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\newcommand{\wbc}[3]{\vspace*{#1}\begin{center}
    \wb{#2}{#2}#3\end{center}\vspace*{#1}}

%\fancyhf{}
%\lhead{\setlength{\unitlength}{1bp}%
%  \begin{picture}(0,0)
%    %\put(-36,5){\makebox(0,0)[br]{\wb{36bp}{36bp} %A}}
 %   \end{picture}}
%\rhead{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
 %   %\put(29,5){\makebox(0,0)[bl]{\wb{36bp}{36bp %}B}}
  %  \end{picture}}
%\lfoot{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
  %  \put(-36,-3){\makebox(0,0)[tr]{\wb{36bp}{36bp}C}}
   % \end{picture}}
%\rfoot{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
  %  \put(29,-3){\makebox(0,0)[tl]{\wb{36bp}{36bp}D}}
   % \end{picture}}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\lhead{\wb{12bp}{12bp}% 
    \begin{picture}(0,0)(59,0)
%{T}{\_}    
%{R}{\_}{O}{\_}{F}{\_}{U}   
    \put(0,0){M}
    \multiput(13,0)(13,0){30}{N}
    \put(403,0){O}
    \put(0,-533){P}
    \multiput(0,-13)(0,-13){40}{S}
    \multiput(13,-533)(13,0){30}{Q}
    \put(403,-533){R}
    \multiput(403,-13)(0,-13){40}{T}
    \end{picture}
    %\begin{picture}
    %\multiput(-18,0)(18,0){24}{N}
    %\put(450,0){M}
    %\multiput(0,-18)(0,18){34}{T}
    %\put(0,630){R}
    %\multiput(18,0)(18,630){24}{Q}
    %\multiput(0,18)(450,18){34}{S}
    %\put(450,630){P}
    %\end{picture}
%\vspace{length}
{   \normalfont \thepage}
    }
\fancyhead[RH]{\flushright  \normalfont \thepage}

%\lhead{\thepage}
%\chead{}
\rhead{}
\cfoot{\vspace{2em}\thepage} % get rid of the page number 
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\begin{document}
  The King and Queen of Hearts were seated on their throne
  when they arrived, with a great crowd assembled about them
  --- all sorts of little birds and beasts, as well as the
  whole pack of cards: the Knave was standing before them,
  in chains, with a soldier on each side to guard him; and
  near the King was the White Rabbit, with a trumpet in one
  hand, and a scroll of parchment in the other.  In the very
  middle of the court was a table, with a large dish of
  tarts upon it: they looked so good, that it made Alice
  quite hungry to look at them --- ``I wish they'd get the
  trial done,'' she thought, ``and hand round the
  refreshments!''.  But there seemed to be no chance of this,
  so she began looking at everything about her to pass away
  the time.

  \wbc{2ex}{6}{IJLKIJLKIJLKIJLKIJ}

  Alice had never been in a court of justice before, but she
  had read about them in books, and she was quite pleased to
  find that she knew the name of nearly everything there.
  ``That's the judge,'' she said to herself, ``because of his
  great wig.''.

  The judge, by the way, was the King, and as he wore his
  crown over the wig, (look at the frontispiece if you want
  to see how he did it,) he did not look at all comfortable,
  and it was certainly not becoming.

  \wbc{1ex}{8}{pq}

  ``And that's the jury-box,'' thought Alice, ``and those
  twelve creatures,'' (she was obliged to say ``creatures,''
  you see, because some of them were animals, and some were
  birds) ``I suppose they are the jurors.''.  She said this
  last word two or three times over to herself being rather
  proud of it: for she thought, and rightly too, that very
  few little girls of her age knew the meaning of it at all.
  However, ``jurymen'' would have done just as well.

  \wbc{1ex}{10}{ced}

  The twelve jurors were all writing very busily on slates.
  ``What are they doing?'' Alice whispered to the Gryphon.
  ``They can't have anything to put down yet, before the
  trial's begun.''.

  ``They're putting down their names,'' the Gryphon
  whispered in reply, ``for fear they should forget them
  before the end of the trial.''.

  ``Stupid things!'' Alice began in a loud indignant voice,
  but she stopped herself hastily, for the White Rabbit
  cried out, ``Silence in the court!''; and the King put on
  his spectacles and looked anxiously round, to make out who
  was talking.
\end{document}

% $Id: sample1.tex,v 1.3 2002/09/13 06:34:25 loreti Exp $
  1. 有没有办法让页码向左/向右而不是居中?

  2. 我主要使用回忆录类,如何在没有 fancyhdr 的情况下使用回忆录类做同样的事情?

答案1

使用memoir,您首先使用声明页面样式

\makepagestyle{<name>}

是您为页面样式选择的名称。然后使用以下方式定义页眉/页脚

\makeevenhead{<name>}{<left>}{<center>}{<right>}
\makeoddhead{<name>}{<left>}{<center>}{<right>}
\makeevenfoot{<name>}{<left>}{<center>}{<right>}
\makeoddfoot{<name>}{<left>}{<center>}{<right>}

您的第一个样式的示例:

\documentclass[a4paper]{memoir}
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage[english]{babel}

\usepackage{blindtext}

\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\newcommand{\wbc}[3]{\vspace*{#1}\begin{center}
    \wb{#2}{#2}#3\end{center}\vspace*{#1}}

\makepagestyle{myps}
\makeevenhead{myps}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(-36,5){\makebox(0,0)[br]{\wb{36bp}{36bp}A}}
    \end{picture}
  }
  {}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(29,5){\makebox(0,0)[bl]{\wb{36bp}{36bp}B}}
    \end{picture}
  }
\makeoddhead{myps}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(-36,5){\makebox(0,0)[br]{\wb{36bp}{36bp}A}}
    \end{picture}%
  }
  {}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(29,5){\makebox(0,0)[bl]{\wb{36bp}{36bp}B}}
    \end{picture}%
  }
\makeevenfoot{myps}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(-36,-3){\makebox(0,0)[tr]{\wb{36bp}{36bp}C}}
    \end{picture}%
  }
  {}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(29,-3){\makebox(0,0)[tl]{\wb{36bp}{36bp}D}}
    \end{picture}%
  }
\makeoddfoot{myps}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(-36,-3){\makebox(0,0)[tr]{\wb{36bp}{36bp}C}}
    \end{picture}%
  }
  {}
  {\setlength{\unitlength}{1bp}%
  \begin{picture}(0,0)
    \put(29,-3){\makebox(0,0)[tl]{\wb{36bp}{36bp}D}}
    \end{picture}%
  }

\pagestyle{myps}

\begin{document}
 \blindtext[10]
  \wbc{2ex}{6}{IJLKIJLKIJLKIJLKIJ}

 \blindtext[3]

  \wbc{1ex}{8}{pq}


\end{document}

在此处输入图片描述

而且,使用第二种样式(请注意\makeevenfoot\makeoddfoot用于将页码放置在框架下方):

\documentclass[10pt,twoside]{memoir}
\usepackage{geometry,keyval,ifthen,makeidx,multicol,mparhack}
\usepackage{times}
\geometry{textwidth=4in,textheight=6.75in}

\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
%\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\newcommand{\wbc}[3]{\vspace*{#1}\begin{center}
    \wb{#2}{#2}#3\end{center}\vspace*{#1}}

%\fancyhf{}
%\lhead{\setlength{\unitlength}{1bp}%
%  \begin{picture}(0,0)
%    %\put(-36,5){\makebox(0,0)[br]{\wb{36bp}{36bp} %A}}
 %   \end{picture}}
%\rhead{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
 %   %\put(29,5){\makebox(0,0)[bl]{\wb{36bp}{36bp %}B}}
  %  \end{picture}}
%\lfoot{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
  %  \put(-36,-3){\makebox(0,0)[tr]{\wb{36bp}{36bp}C}}
   % \end{picture}}
%\rfoot{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
  %  \put(29,-3){\makebox(0,0)[tl]{\wb{36bp}{36bp}D}}
   % \end{picture}}

\makepagestyle{mypsii}
\makeevenhead{mypsii}
  {\wb{12bp}{12bp}% 
    \begin{picture}(0,0)(59,0)
%{T}{\_}    
%{R}{\_}{O}{\_}{F}{\_}{U}   
    \put(0,0){M}
    \multiput(13,0)(13,0){30}{N}
    \put(403,0){O}
    \put(0,-533){P}
    \multiput(0,-13)(0,-13){40}{S}
    \multiput(13,-533)(13,0){30}{Q}
    \put(403,-533){R}
    \multiput(403,-13)(0,-13){40}{T}
    \end{picture}%
  }
  {}
  {}
\makeoddhead{mypsii}
  {\wb{12bp}{12bp}% 
    \begin{picture}(0,0)(59,0)
%{T}{\_}    
%{R}{\_}{O}{\_}{F}{\_}{U}   
    \put(0,0){M}
    \multiput(13,0)(13,0){30}{N}
    \put(403,0){O}
    \put(0,-533){P}
    \multiput(0,-13)(0,-13){40}{S}
    \multiput(13,-533)(13,0){30}{Q}
    \put(403,-533){R}
    \multiput(403,-13)(0,-13){40}{T}
    \end{picture}%
  }
  {}
  {}
\makeevenfoot{mypsii}
  {\put(360,-3){\makebox(0,0)[tr]{\normalfont \thepage}}}
  {}
  {}
\makeoddfoot{mypsii}
  {\put(-55,-3){\makebox(0,0)[tr]{\normalfont \thepage}}}
  {}
  {}

\pagestyle{mypsii}

\begin{document}
  The King and Queen of Hearts were seated on their throne
  when they arrived, with a great crowd assembled about them
  --- all sorts of little birds and beasts, as well as the
  whole pack of cards: the Knave was standing before them,
  in chains, with a soldier on each side to guard him; and
  near the King was the White Rabbit, with a trumpet in one
  hand, and a scroll of parchment in the other.  In the very
  middle of the court was a table, with a large dish of
  tarts upon it: they looked so good, that it made Alice
  quite hungry to look at them --- ``I wish they'd get the
  trial done,'' she thought, ``and hand round the
  refreshments!''.  But there seemed to be no chance of this,
  so she began looking at everything about her to pass away
  the time.

  \wbc{2ex}{6}{IJLKIJLKIJLKIJLKIJ}

  Alice had never been in a court of justice before, but she
  had read about them in books, and she was quite pleased to
  find that she knew the name of nearly everything there.
  ``That's the judge,'' she said to herself, ``because of his
  great wig.''.

  The judge, by the way, was the King, and as he wore his
  crown over the wig, (look at the frontispiece if you want
  to see how he did it,) he did not look at all comfortable,
  and it was certainly not becoming.

  \wbc{1ex}{8}{pq}

  ``And that's the jury-box,'' thought Alice, ``and those
  twelve creatures,'' (she was obliged to say ``creatures,''
  you see, because some of them were animals, and some were
  birds) ``I suppose they are the jurors.''.  She said this
  last word two or three times over to herself being rather
  proud of it: for she thought, and rightly too, that very
  few little girls of her age knew the meaning of it at all.
  However, ``jurymen'' would have done just as well.

  \wbc{1ex}{10}{ced}

  The twelve jurors were all writing very busily on slates.
  ``What are they doing?'' Alice whispered to the Gryphon.
  ``They can't have anything to put down yet, before the
  trial's begun.''.

  ``They're putting down their names,'' the Gryphon
  whispered in reply, ``for fear they should forget them
  before the end of the trial.''.

  ``Stupid things!'' Alice began in a loud indignant voice,
  but she stopped herself hastily, for the White Rabbit
  cried out, ``Silence in the court!''; and the King put on
  his spectacles and looked anxiously round, to make out who
  was talking.
\end{document}

在此处输入图片描述

第一页底部的放大图像,显示页码:

在此处输入图片描述

使用的fancyhdr想法是一样的,但是使用包接口:

\fancyfoot[LO]{<code for page number>}
\fancyfoot[RE]{<code for page number>}

或者

\fancyfoot[LO,RE]{<code for page number>}

如果代码相似。

使用 fancyhdr 和第二种样式的示例:

\documentclass[10pt,twoside]{book}
\usepackage{fancyhdr,geometry,keyval,ifthen,makeidx,multicol,mparhack,poemscol}
\usepackage{times}
\geometry{textwidth=4in,textheight=6.75in}
\makeverselinenumbers
\global\includeaccidentalstrue
\global\includetypescriptstrue
\global\redundantemendationsfalse
\stanzaatbottom{*}
\nostanzaatbottom{\relax}
%\reversemarginpar

\setlength\headheight{12.05pt}

\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
%\newcommand{\wb}[2]{\fontsize{#1}{#2}\usefont{U}{webo}{xl}{n}}
\newcommand{\wbc}[3]{\vspace*{#1}\begin{center}
    \wb{#2}{#2}#3\end{center}\vspace*{#1}}

%\fancyhf{}
%\lhead{\setlength{\unitlength}{1bp}%
%  \begin{picture}(0,0)
%    %\put(-36,5){\makebox(0,0)[br]{\wb{36bp}{36bp} %A}}
 %   \end{picture}}
%\rhead{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
 %   %\put(29,5){\makebox(0,0)[bl]{\wb{36bp}{36bp %}B}}
  %  \end{picture}}
%\lfoot{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
  %  \put(-36,-3){\makebox(0,0)[tr]{\wb{36bp}{36bp}C}}
   % \end{picture}}
%\rfoot{\setlength{\unitlength}{1bp}%
 % \begin{picture}(0,0)
  %  \put(29,-3){\makebox(0,0)[tl]{\wb{36bp}{36bp}D}}
   % \end{picture}}
\renewcommand{\headrulewidth}{0pt}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\wb{12bp}{12bp}% 
    \begin{picture}(0,0)(59,0)
%{T}{\_}    
%{R}{\_}{O}{\_}{F}{\_}{U}   
    \put(0,0){M}
    \multiput(13,0)(13,0){30}{N}
    \put(403,0){O}
    \put(0,-533){P}
    \multiput(0,-13)(0,-13){40}{S}
    \multiput(13,-533)(13,0){30}{Q}
    \put(403,-533){R}
    \multiput(403,-13)(0,-13){40}{T}
    \end{picture}
    %\begin{picture}
    %\multiput(-18,0)(18,0){24}{N}
    %\put(450,0){M}
    %\multiput(0,-18)(0,18){34}{T}
    %\put(0,630){R}
    %\multiput(18,0)(18,630){24}{Q}
    %\multiput(0,18)(450,18){34}{S}
    %\put(450,630){P}
    %\end{picture}
%\vspace{length}
}
\fancyfoot[LO]{%
  \leavevmode
  \put(359,-3){\makebox(0,0)[tr]{\normalfont\thepage}}
}
\fancyfoot[RE]{%
  \leavevmode  
  \put(-344,-3){\makebox(0,0)[tr]{\normalfont\thepage}}
}

\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\begin{document}
  The King and Queen of Hearts were seated on their throne
  when they arrived, with a great crowd assembled about them
  --- all sorts of little birds and beasts, as well as the
  whole pack of cards: the Knave was standing before them,
  in chains, with a soldier on each side to guard him; and
  near the King was the White Rabbit, with a trumpet in one
  hand, and a scroll of parchment in the other.  In the very
  middle of the court was a table, with a large dish of
  tarts upon it: they looked so good, that it made Alice
  quite hungry to look at them --- ``I wish they'd get the
  trial done,'' she thought, ``and hand round the
  refreshments!''.  But there seemed to be no chance of this,
  so she began looking at everything about her to pass away
  the time.

  \wbc{2ex}{6}{IJLKIJLKIJLKIJLKIJ}

  Alice had never been in a court of justice before, but she
  had read about them in books, and she was quite pleased to
  find that she knew the name of nearly everything there.
  ``That's the judge,'' she said to herself, ``because of his
  great wig.''.

  The judge, by the way, was the King, and as he wore his
  crown over the wig, (look at the frontispiece if you want
  to see how he did it,) he did not look at all comfortable,
  and it was certainly not becoming.

  \wbc{1ex}{8}{pq}

  ``And that's the jury-box,'' thought Alice, ``and those
  twelve creatures,'' (she was obliged to say ``creatures,''
  you see, because some of them were animals, and some were
  birds) ``I suppose they are the jurors.''.  She said this
  last word two or three times over to herself being rather
  proud of it: for she thought, and rightly too, that very
  few little girls of her age knew the meaning of it at all.
  However, ``jurymen'' would have done just as well.

  \wbc{1ex}{10}{ced}

  The twelve jurors were all writing very busily on slates.
  ``What are they doing?'' Alice whispered to the Gryphon.
  ``They can't have anything to put down yet, before the
  trial's begun.''.

  ``They're putting down their names,'' the Gryphon
  whispered in reply, ``for fear they should forget them
  before the end of the trial.''.

  ``Stupid things!'' Alice began in a loud indignant voice,
  but she stopped herself hastily, for the White Rabbit
  cried out, ``Silence in the court!''; and the King put on
  his spectacles and looked anxiously round, to make out who
  was talking.
\end{document}

  ``Stupid things!'' Alice began in a loud indignant voice,
  but she stopped herself hastily, for the White Rabbit
  cried out, ``Silence in the court!''; and the King put on
  his spectacles and looked anxiously round, to make out who
  was talking.
\end{document}

第一页底部的图像:

在此处输入图片描述

请根据您的需要随意更改设置。

相关内容