部分之前沒有換行符,保留標題訊息

部分之前沒有換行符,保留標題訊息

我正在努力實現與這篇文章相同的目標: 刪除 *\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}

相關內容