0

I am trying to achieve the same as this post: Remove newline *before* \section But the problem is that with the suggested solution the section information cannot be used in the header. Is there any way that I can remove the newline before a subsection and at the same time keep the section information for the header? I need a running header with the first and last section and subsection information.

Basically I'm trying to achieve a combination of this: No newline before section, preserve header info

And this: Chapters and verses of current page in header

1 Answers1

1

I think you want something like this, the key is to use \markright (or \markboth or one of the other mark commands) to leave a mark on the page, the page heading can then pick up the first and last mark on the page and use accordingly. In the standard classes \section uses \markright (with chapter level marks using the left mark) so I did the same here, defining a simple \section that uses a counter and leaves a mark but no optional handling or star form, and very little heading formatting

enter image description here

\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}
David Carlisle
  • 757,742