
本のヘッダーにロゴを追加したいです。ロゴは奇数ページまたは偶数ページの左隅または右隅に配置する必要があります。コードの修正を手伝ってください:
\documentclass[
paper=a4, % it's the default anyway
fontsize=12pt,
twoside
]{book}
\usepackage[paperwidth=7.25in, paperheight=9.5in,bindingoffset=.75in]{geometry}
\usepackage{fancyhdr}
\usepackage{makeidx} % allows index generation
\usepackage[demo]{graphicx}
\pagestyle{fancy}
{%
\fancyhead[L]{\includegraphics[width=1.5cm,height=1.5cm,keepaspectratio]{logo.eps}}
\fancyhead[R]{\includegraphics[width=1.5cm,height=1.5cm,keepaspectratio]{logo.eps}}}
\setlength{\headheight}{47.0pt}
\addtolength{\topmargin}{-4\baselineskip}
\usepackage{lipsum}
\begin{document}
\lipsum
\newpage
\lipsum
\end{document}
答え1
パッケージはデフォルトでいくつかの非推奨のコマンドを使用しています。しかし、デフォルトをfancyhdr
使用してクリアした後は、もう問題にはなりません(ありがとう\fancyhf
エグレ)。
scrlayer-scrpage
KOMAバンドルのパッケージを使用することをお勧めします。構文はほぼ同じです。\lehead
は、左偶数頭\rohead
、右奇数ヘッド。フッターの命名規則も同様です (\lofoot
など\cefoot
)。
\documentclass{book}
\usepackage[paperwidth=7.25in,
paperheight=9.5in,bindingoffset=.75in]{geometry}
\usepackage[headsepline]{scrlayer-scrpage}
\usepackage{mwe}
\lehead{\includegraphics[height=1.5cm,keepaspectratio]{example-image-a}}
\rohead{\includegraphics[height=1.5cm,keepaspectratio]{example-image-b}}
\setlength{\headheight}{47.0pt}
\begin{document}
\lipsum[1-20]
\end{document}
注:book
外側のヘッダーにページ番号を設定します。パッケージはscrlayer-scrpage
、ユーザーから要求された場合にそれを上書きします。パッケージは、fancyhdr
ユーザーの操作なしでブックの設定を上書きします。
答え2
fancyhdr
は、dd ページO
とE
ven ページの配置と、ページのL
左または右の選択を提供しますR
。したがって、 dd ページL
の左サイドには を使用し、ven ページの右サイドには を使用します。O
LO
R
E
RE
\documentclass[twoside]{book}
\usepackage[paperwidth=7.25in, paperheight=9.5in,bindingoffset=.75in]{geometry}
\usepackage{fancyhdr,graphicx,lipsum}
\pagestyle{fancy}
\fancyhead[LO]{\includegraphics[width=1.5cm,height=1.5cm,keepaspectratio]{example-image-a}}
\fancyhead[RE]{\includegraphics[width=1.5cm,height=1.5cm,keepaspectratio]{example-image-b}}
\setlength{\headheight}{47.0pt}
\begin{document}
\lipsum[1-20]
\end{document}
book
ドキュメント クラスは、\thispagestyle{plain}
すべての の最初のページで発行されることに注意してください。その場合、 を再発行または再定義しない限り、ページ スタイル\chapter
は失われます。fancy
\pagestyle{fancy}
plain