在标题中的图像和行之间添加空格

在标题中的图像和行之间添加空格

--- 编辑 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在你的后面添加一个\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}

相关内容