I want to have the following document structure:
Exercise 1 %sections
a) %subsections
b)
Exercise 2
I found the following solution to put the section title before the numbering and changing the subsection number format:
\renewcommand{\thesubsection}{\alph{subsection})}
\titleformat{\section}[runin]{\normalfont\Large\bfseries}{}{0pt}{#1\ \thesection\\}
\titleformat{\subsection}[runin]{\normalfont\large\bfseries}{}{0pt}{#1\ \thesubsection\\}
Btw: Can I shift the whole subsection part to the right?
However I am using the package scrlayer-scrpage to define a footer and a header. In the inner footer a text should display the exercise number, which is the section number. So I used \headmark for this but it always displays the number before the term "Exercise". How can I change it?
This is a minimal example:
% !TeX encoding = UTF-8
\documentclass[a4paper,10pt,headsepline,footsepline,abstracton,notitlepage]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{scrlayer-scrpage}
\usepackage[explicit]{titlesec}
\renewcommand{\thesubsection}{\alph{subsection})}
\titleformat{\section}[runin]{\normalfont\Large\bfseries}{}{0pt}
{#1\ \thesection\\}
\titleformat{\subsection}[runin]{\normalfont\large\bfseries}{}{0pt}
{#1\ \thesubsection\\}
\automark{section}
\clearpairofpagestyles
\ihead{Author}
\ohead{\today}
\ifoot{\headmark}
\cfoot{Course xxx }
\ofoot{\pagemark}
\author{Chuck Norris}
\date{\today}
\title{xxx - Sheet 42}
\begin{document}
\maketitle
\begin{abstract}
asdfahadga
\end{abstract}
\newpage
\section{Exercise}
tsestsfadf
\newpage
\subsection{Part }
asdf
\newpage
\section{Exercise}
\subsection{Part}
asdfadga
\subsection{Part}
\newpage
\end{document}
Best Answer
To change the order of section text and number in the page header or footer redefine
\sectionmark
But note that it is not recommended to use
titlesec
together with a KOMA-Script class. You can redefine\sectionlinesformat
to change the order of text and number for section and subsection headings:To redefine the format of the numbers in section and subsection headings use
To change or set the font of the section and subsection headings use
To change the order of section text and number in the page header or footer redefine
\sectionmark
as suggested aboveThe last line ensures that the section number in the page header/footer is formatted in the same way as in the section heading.
Code:
To indent the whole subsection part you could use
addmargin
.Result
With a KOMA-Script Version older than 3.19 (current is 3.21) you have to use
titlesec
to change the order of the section number and text. Note that this is not recommended for version 3.19 or newer (see above).