書頁眉左右兩側的標誌(雙面)

書頁眉左右兩側的標誌(雙面)

我想在一本書的頁首中添加徽標。徽標應位於奇數/偶數頁的左側或右側角。請幫我修正我的程式碼:

\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-bundlea 中的軟體包。語法非常相似。\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提供Odd 和Even 頁面放置以及在頁面的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

相關內容