Replace part number by an acronym
The MWE in the question already contains a redefinition of \thechapter
. This can be customized further by replacing the part counter \thepart
with a new macro that contains the required abbreviation.
To set this using an optional argument to \part
the old definition of \part
can be stored in another macro such as \oldpart
, and then \part
can be redefined to accept an optional argument, store that in a macro, and then call the \oldpart
macro which will process the default argument, similar to Optional arguments in \def. The default value of the optional argument is \thepart
, to allow parts without a label to be numbered with the roman part number.
When a Table of Contents is printed the chapter labels do not fit the default width, this can be addressed using \RedeclareSectionCommand
.
MWE:
\documentclass[oneside]{scrbook}
\RedeclareSectionCommand[
tocnumwidth=1.5cm
]{chapter}
\let\oldpart\part
\renewcommand\part[1][\thepart]{\def\partacr{#1}\oldpart}
%reset chapter for each part
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\renewcommand{\thechapter}{\partacr.\arabic{chapter}}
\begin{document}
\tableofcontents
\part[ALG]{Algebra}
\chapter{Chap 1}
\chapter{Chap 2}
\part{Geometry}
\chapter{Chap 1}
\chapter{Chap 2}
\end{document}
Result:
Like this?
\documentclass[oneside]{scrbook}
%reset chapter for each part
\makeatletter
\@addtoreset{chapter}{part}
\makeatother
\newcommand{\prt}[2]{\part{#2}
\renewcommand{\thechapter}{#1\arabic{chapter}}}
\usepackage{tocloft}
\renewcommand\cftchapnumwidth{1.2cm} %<-- For tableofcontents
\begin{document}
\tableofcontents
\prt{ALG}{Algebra} %\part[ALG]{Algebra} ?
\chapter{Chap 1}
\prt{ANA}{Analysis}
\chapter{Chap 1}
\prt{GEO}{Geometry}
\chapter{Chap 1}
\end{document}
Here is a simple solution, with an \acropart
command to be used just after the \part
command:
\documentclass[oneside]{scrbook}
\counterwithin*{chapter}{part}
\makeatletter
\DeclareRobustCommand\acropart[1]{\gdef\@acropart{#1}}
\renewcommand{\thechapter}{\@acropart.~\arabic{chapter}}
\makeatother
\makeatother
\begin{document}
\part{Algebra} %\part[ALG]{Algebra} ?
\acropart{ALG}
\chapter{Chapter the first}
\chapter{Chapter the second}
\part{Analysis}
\acropart{ANAL}
\chapter{Chapter the first}
\part{Geometry}
\acropart{GEOM}
\chapter{Chapter the first}
\end{document}