Home >[TeX] >[Package] >[fancyhdr] Version: 4.1 2022-11-09
fancyhdr (download here)
[パッケージについて]

[articleの場合] [bookの場合] [reportの場合]

[articleの場合]

1.
  \pagestyle{fancy}
  \rhead{\leftmark}
  \lhead{\rightmark}
  • ヘッダーの部分の右に節番号、タイトル、真ん中はなし、左もなし、柱の罫線あり。
  • フッターの部分の左は、なし、真ん中にページ番号、右はなし、柱の罫線なし。
fancyhdr
[上のソースファイル]
各節の始まりに
  \section{最初}
  \thispagestyle{fancy}
を入れることで、他のページと同じ様式になります。

2.
  \pagestyle{fancy}
  \lhead{}
  \chead{Headerの真ん中}
  \rhead{\thepage}
  \cfoot{}
  • ヘッダーの部分の左は、なし、真ん中は上で指定した”ヘッダーの真ん中”、右はページ数、柱の罫線あり。
  • フッターの部分の左は、なし、真ん中もなし、右もなし、柱の罫線なし。
fancyhdr
[上のソースファイル]

3.
  \pagestyle{fancy}
  \lhead{}
  \chead{Headerの真ん中}
  \rhead{\thepage}
  \lfoot{左下}
  \cfoot{Fotterの真ん中}
  \rfoot{\thepage}
  \renewcommand{\footrulewidth}{0.4pt}
  • ヘッダーの部分の左は、なし、真ん中は上で指定した”ヘッダーの真ん中”、右はページ数、柱の罫線あり。
  • フッターの部分の左は、”左下”、真ん中は、”フッターの真ん中”、右は、ページ数、柱の罫線あり。
      0.4ptがデフォルトの線の太さ。罫線が必要ないときは、0.0ptとする。
      \renewcommand{\headrulewidth}{0.0pt}により、上部の罫線がなくなる。
fancyhdr
[上のソースファイル]
 破線にしたときは
  \renewcommand\headrule{\vspace{-8pt}\dotfill}
を用いる。
 二重線にしたときは
  \makeatletter
  \def\headrule{{%
  \if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
  \hrule\@height\headrulewidth\@width\headwidth\vskip2pt%
  \hrule\@height\headrulewidth\@width\headwidth\vskip-\headrulewidth\vskip-4pt
  }}
  \makeatother
の前に入れます。

4.
  \usepackage{lastpage}
  \pagestyle{fancy}
  \lhead{}
  \rhead{}
  \cfoot{\thepage{}/{}\pageref{LastPage}}
  • ヘッダーの部分の左は、なし、真ん中はなし、右もなし、柱の罫線あり。
  • フッターの部分の左は、なし、真ん中に、”ページ番号/総ページ数”、右は、なし、柱の罫線なし。
fancyhdr
[上のソースファイル]
  • ヘッダーの部分の左は、なし、真ん中はなし、右もなし、柱の罫線なし。
  • フッターの部分の左は、なし、真ん中に、”-- ページ番号 --”、右は、なし、柱の罫線なし。
fancyhdr
[上のソースファイル]

5.
上の状況にhyperrefを組み合わせる。
  \cfoot{\thepage{}/{}\protect\pageref*{LastPage}}
に変更します。
*
[上のソースファイル]

6.
右上にページ数を”1/総ページ数”の形で表示。他は、なし。
  \usepackage{lastpage}
  \pagestyle{fancy}
  \lhead{}
  \rhead{\thepage{}/{}\pageref{LastPage}}
  \cfoot{} 
  \renewcommand{\headrulewidth}{0pt}
fancyhdr
[上のソースファイル]

7.
ヘッダーの左は”日付”、右は\oldstyenumsの書体でページ数。フッターの右にも同じ書体でページ数。
  \usepackage{lastpage} 
  \pagestyle{fancy} 
  \lhead{\today}
  \rhead{[\ \scshape\oldstylenums{\thepage}\ / %
      \scshape\oldstylenums{\pageref{LastPage}}\ ]}
  \cfoot{}
  \rfoot{[\ \scshape\oldstylenums{\thepage}\ / %
      \scshape\oldstylenums{\pageref{LastPage}}\ ]}
fancyhdr
[上のソースファイル]

8.
フッターの左にタイトルを入れる。ページ数は、右。
  \pagestyle{fancy} 
  \let\origtitle\title 
  \renewcommand{\title}[1]{\lfoot{#1}\origtitle{#1}}
  \cfoot{}
  \rfoot{\thepage}
fancyhdr
[上のソースファイル]

9.
フッターの真ん中に著者を入れる。ページ数は、右。
  \pagestyle{fancy} 
  \let\origauthor\author 
  \renewcommand{\author}[1]{\cfoot{#1}\origauthor{#1}}
  \lfoot{}
  \rfoot{\thepage}
fancyhdr
[上のソースファイル]

10.
用紙左上に図を入れる。
fancyhdr
[上のソースファイル]

11.
用紙右上に図を入れる。
fancyhdr
[上のソースファイル]
textpos参照。

12.
最後のページの表示を変える。
fancyhdr
[上のソースファイル]
fancyhdr
[上のソースファイル]

13.
ページスタイルの定義を用いる。
fancyhdr
[上のソースファイル]

14.
ページスタイルの定義を用いる。
fancyhdr
[上のソースファイル]

15.
ページスタイルの定義を用いる。
fancyhdr
[上のソースファイル]

16.
twosideを指定し、1頁目はタイトルページ、2ページ目以降でfancyhdrを利用。
fancyhdr14.gif
[上のソースファイル]
TeX -- etc 2参照。

17.
twosideを指定し、
 奇数ページは左フッター部分に文字
 偶数ページは右ヘッダー部分にページ数、右フッター部分に文字列
を入れる。
fancyhdr
[上のソースファイル]
色をつける。
fancyhdr
[上のソースファイル]

18.
twosideを指定し、
 奇数ページは左フッター部分に文字
 偶数ページは右ヘッダー部分にページ数、右フッター部分に文字列
を入れ、ヘッダー部は偶数ページと奇数ページで異なるものを表示する。
fancyhdr
[上のソースファイル]

19.
twosideを指定し、ツメを付ける。
fancyhdr
[上のソースファイル]

出席表:geometrylistliketablastpagelongtablemakecellを伴う。
%%
[上のソースファイル]

*   *
* 2001.tex * letter6.tex
* stationery5.tex * stationery6.tex
* 卒業論文 例 * 卒業論文 2 例
* 卒業論文 3 例 * 卒業論文 4 例

fancyhdrを用いない場合

1.
fancyhdrを入れなく、
  \makeatletter
  \def\@oddhead{\dotfill{\normalfont 暑い}\dotfill}
  \def\@oddfoot{\normalfont\rmfamily\dotfill Page \thepage\dotfill}
  \def\ps@titlepage{\let\@oddhead\@empty}
  \makeatother
をプレアンブルに入れる。
ftry11.gif
[上のソースファイル]
2.
\usepackage[pagestyles]{titlesec}
  \newpagestyle{myps}[\small\sffamily\slshape]{
    \headrule
    \sethead{タイトル}{\sectiontitle}{\usepage}} 
  \pagestyle{myps}
を入れる。
ftry12.gif
[上のソースファイル]
3.
ファイル名、日付、ページ数・総ページ数を入れる。
ftry13.gif
[上のソースファイル]
4.
ページ数を-で囲む。
ftry14.gif
[上のソースファイル]

[articleの場合] [bookの場合] [reportの場合]

   Tips
  Package Fancyhdr Warning: \headheight is too small (12.0pt): 
  Make it at least 15.0pt.
  We now make it that large for the rest of the document.
  This may cause the page layout to be inconsistent, however.
というような警告が出たときは、
  \setlength{\headheight}{15pt}
をプレアンブルに入れると警告がなくなります。

fancyheadingsを用いると下記のような警告がでます。
  Package fancyheadings Warning: Please stop using fancyheadings!
  (fancyheadings)                Use fancyhdr instead.
  (fancyheadings)                We will call fancyhdr with the very same
  (fancyheadings)                options you passed to fancyheadings.
  (fancyheadings)                
  (fancyheadings)                fancyhdr is 99 percent compatible with
  (fancyheadings)                fancyheadings. The only incompatibility is
  (fancyheadings)                that \headrulewidth and \footrulewidth and
  (fancyheadings)                their \plain... versions are no longer length
  (fancyheadings)                parameters, but normal macros (to be changed
  (fancyheadings)                with \renewcommand rather than \setlength)..
[パッケージについて]

[articleの場合] [bookの場合] [reportの場合]


@

To the TeX Page
TeX

@

inserted by FC2 system