
---編輯2 ---
我使用圖像編輯器創建了以下標題,以幫助你們理解我想要做什麼。
--- 編輯 2 結束 ---
--- 編輯 1 ---
這更接近我標題中的內容。只是我沒有實際寫“第 1 章”和“小節”,而是使用 \rightmark 和 \leftmark,但結果基本上相同。當然,我使用的是不同的圖像。問題出在穿過影像的線。或者也許與標題行的長度有關。
--- 編輯 1 結束 ---
好吧,我想我已經到處搜索過這個問題,但找不到答案。有誰知道如何在圖像和標題行之間放置一個空格,以便該線不會穿過圖像?這是我到目前為止所擁有的。
\documentclass[12pt,twoside]{report}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{blindtext}
\pagestyle{fancy}
% ---------------------------- Header ---------------------------- %
\fancyhead{}
\fancyhead[RE,RO]{\nouppercase{Subsection 1.1}}
\fancyhead[CO,CE]{\MakeUppercase{Chapter 1}}
\fancyhead[L]{\raisebox{-.6\height}[0pt][0pt]{\includegraphics[width=1cm]{example-image-a}}}
% ---------------------------- Footer ---------------------------- %
\fancyfoot{}
\fancyfoot[RE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\blindtext
\end{document}
答案1
一個簡單的解決方案重新定義\headrule
以微調其位置:
\documentclass[12pt,twoside]{report}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{blindtext}
\pagestyle{fancy}
% ---------------------------- Header ---------------------------- %
\fancyhead{}
\fancyhead[RE,RO]{\nouppercase{Subsection 1.1}}
\fancyhead[CO,CE]{\MakeUppercase{Chapter 1}}
\fancyhead[L]{\raisebox{-.7\height}[0pt][0pt]{\includegraphics[width=1cm]{example-image-a}}}
% ---------------------------- Footer ---------------------------- %
\fancyfoot{}
\fancyfoot[RE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\renewcommand{\headrule}{\hspace*{1.2cm}\rule[2ex]{\dimexpr\textwidth-1.2cm}{0.4pt}}
\begin{document}
\blindtext
\end{document}
答案2
\vspace
在你的 should 後面添加一個\includegraphics
就可以了。不需要 razebox:
\documentclass[12pt,twoside]{report}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{blindtext}
\pagestyle{fancy}
% ---------------------------- Header ---------------------------- %
\fancyhead{} % blank \fancyhead command which clears all the header fields.%
% --------- The lines below are commented because I'm using in the original file, but I think that there is no need for it in here. ---------
% \fancyhead[RE,RO]{\nouppercase{\rightmark}}
% \renewcommand{\chaptermark}[1]{%
% \markboth{#1}{}}
% \fancyhead[CO,CE]{\MakeUppercase{\leftmark}}
\fancyhead[L]{\includegraphics[width=1cm]{example-image-a}\vspace{3pt}}
% ---------------------------- Footer ---------------------------- %
\fancyfoot{} %Clears the footer fields using a blank \fancyfoot command.%
\fancyfoot[RE,RO]{\thepage} % makes the page number appear on the right of the footer for an even page and the right for an odd. The \thepage command returns the page number of the page it's used on.
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\begin{document}
\blindtext
\end{document}