本のヘッダーの左側と右側にロゴ(両面)

本のヘッダーの左側と右側にロゴ(両面)

本のヘッダーにロゴを追加したいです。ロゴは奇数ページまたは偶数ページの左隅または右隅に配置する必要があります。コードの修正を手伝ってください:

\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-scrpageKOMAバンドルのパッケージを使用することをお勧めします。構文はほぼ同じです。\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 ページOEven ページの配置と、ページのL左または右の選択を提供しますR。したがって、 dd ページLの左サイドには を使用し、ven ページの右サイドには を使用します。OLORERE

ここに画像の説明を入力してください

\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

関連情報