我有一个类,其中使用makemargins
命令定义页眉和页脚:
\newcommand{\makemargins}{
\makenomenclature
\pagestyle{fancy}
\fancyheadoffset{1cm}
\setlength{\headheight}{2cm}
\lhead{\includegraphics[width=0.25\textwidth]{./logos/logo.pdf}} % Set image at top of the page
\rhead{\nouppercase{\rightmark}}
\rfoot{\thepage}
\cfoot{\textbf{\reporttitle}}
\lfoot{\coursecode}
}
但是,当定义我的右侧标题的部分标题很长时,我会遇到麻烦,因为文本与左侧标题中的徽标重叠,如下图所示:
如何设置右侧标题的最大水平尺寸,以便长文本自动分成多行?
编辑
MWE补充道:
\documentclass[a4paper,12pt]{article}
%--------------------- General Packages ------------------------
\usepackage[english]{babel} % Language of the document
\usepackage{graphicx} % Insert figures
\usepackage{fancyhdr}
% Page configuration
\usepackage{geometry}
\geometry{a4paper,hscale=0.75,vscale=0.8}
% Package for references with numbers
\bibliographystyle{apsrev4-1}
\usepackage[numbers]{natbib}
\setcitestyle{numbers}
% Command for settings of headers and footers
\newcommand{\makemargins}{
\pagestyle{fancy}
\fancyheadoffset{1cm}
\setlength{\headheight}{2cm}
\lhead{\includegraphics[width=0.15\textwidth]{example-image-a}} % Set image at top of the page
\rhead{\nouppercase{\rightmark}}
}
\begin{document}
\makemargins
\tableofcontents
\newpage
\section{Very very very very very very very very very very very very very very very long section 1}
\end{document}
顺便说一句,如果我从上面的 MWE 中删除与书目相关的部分(见下文),则章节标题会从右侧页眉中消失(使用 Overleaf)。为什么会发生这种情况?我认为我为书目设置的任何内容都与页眉和页脚无关。
% Package for references with numbers
\bibliographystyle{apsrev4-1}
\usepackage[numbers]{natbib}
\setcitestyle{numbers}
答案1
借助小页面:
\documentclass[a4paper,12pt]{book}
%--------------------- General Packages ------------------------
\usepackage[english]{babel} % Language of the document
\usepackage{graphicx} % Insert figures
\usepackage{fancyhdr}
% Page configuration
\usepackage{geometry}
\geometry{a4paper,hscale=0.75,vscale=0.8}
% Package for references with numbers
\bibliographystyle{apsrev4-1}
\usepackage[numbers]{natbib}
\setcitestyle{numbers}
% Command for settings of headers and footers
\newcommand{\makemargins}{
\pagestyle{fancy}
\fancyheadoffset{1cm}
\setlength{\headheight}{2cm}
\lhead{\includegraphics[width=0.15\textwidth]{example-image-a}} % Set image at top of the page
\rhead{\begin{minipage}[b]{15cm}\nouppercase{\rightmark}\end{minipage}}
}
\begin{document}
\makemargins
\tableofcontents
\newpage
\section{Very very very very very very very very very very very very very very very long section 1}
\newpage
x
\section{section 1}
\newpage
x
\end{document}
(我必须替换 documentclass,因为标题中没有问题中的章节标题)