我正在尝试实现与这篇文章相同的目标: 删除 \section 之前的新行 但问题是,使用建议的解决方案,部分信息不能在标题中使用。有什么方法可以删除子部分之前的换行符,同时保留标题的部分信息?我需要一个包含第一个和最后一个部分以及子部分信息的运行标题。
基本上我想实现以下两者的组合: 部分之前没有换行符,保留标题信息
和这个: 页眉中显示当前页面的章节
答案1
我认为您想要这样的东西,关键是使用\markright
(或\markboth
其他标记命令之一)在页面上留下标记,然后页面标题可以拾取页面上的第一个和最后一个标记并相应地使用。在标准类中\section
使用\markright
(章节级标记使用左标记),所以我在这里做了同样的事情,定义了一个简单的\section
使用计数器并留下标记但没有可选处理或星形形式的标记,并且标题格式很少
\documentclass{report}
\usepackage[paperheight=8cm,paperwidth=7cm, margin=2cm]{geometry}
\pagestyle{headings}
\renewcommand\section[1]{%
\refstepcounter{section}%
\textsection\thesection\markright{#1}~\textit{#1} %
}
\begin{document}
%\chapter{zzz} omit this as page heading is open on chapter start pages by default
\refstepcounter{chapter}
\section{Start} something about the beginning \section{This} and a bit more
\section{That} A longer section about something that has more than one paragraph.
It seems a bit odd to have a paragraph more distinguished than a section heading, so perhaps that is not needed. \section{Then} and sections will always be inline.
\section{Later} or at the start of a paragraph.
\section{Second Start} something about the beginning \section{Second This} and a bit more
\section{Second That} A longer section about something that has more than one paragraph.
It seems a bit odd to have a paragraph more distinguished than a section heading, so perhaps that is not needed. \section{Second Then} and sections will always be inline.
\section{Second Later} or at the start of a paragraph.
\section{Third} Is surprisingly different to the first two.
\end{document}