3

In my scrartcl, I want to modify the subsection numbering as UNIT I, without being preceded by section numbering. How I can do that?

An MWE is:

\documentclass{scrartcl}
\begin{document}
\section{Hello}
\subsection{World}

Instead of \textbf{1.1 World}, I want \textbf{Unit I. World} \end{document}

Ingmar
  • 6,690
  • 5
  • 26
  • 47
BaRud
  • 2,179

2 Answers2

5

I literally googeled "koma latex change subsection" and used the first hit :).

\documentclass{scrartcl}

% https://tex.stackexchange.com/questions/353008 \renewcommand*\thesubsection{Unit \Roman{subsection}}

\begin{document}

\section{Hello} \subsection{World}

\end{document}

enter image description here

3

If your use case doesn't require you to create cross-references to the "units", @Dr.ManuelKuehner's simple and straightforward answer is perfectly adequate.

In, however, if you foresee a need to create cross-references of the units, it's better not to incorporate the word "Unit" directly into the macro \thesubsection. Instead, it would be better to make use of the low-level LaTeX command \@seccntformat; see below for an implementation of this idea. If you pursue this approach, as an added bonus you can make use of the cross-referencing capabilities of the cleveref package, e.g., use a \cref or \Cref command to create a cross-referencing call-out to multiple objects in one go.

Incidentally, the \@seccntformat approach works equally well with the Koma-Script document classes and with the "basic" LaTeX document classes (article, report and book).

enter image description here

\documentclass{scrartcl}

% Method proposed in "The LaTeX Companion", 2nd ed.: \makeatletter \def@seccntformat#1{@ifundefined{#1@cntformat}% {\csname the#1\endcsname\space}% default {\csname #1@cntformat\endcsname}}% enable individual control \newcommand\subsection@cntformat{Unit \thesubsection@.\space} % subsection level \makeatother

\renewcommand\thesubsection{\Roman{subsection}}

\usepackage{cleveref} % for \cref and \Cref macros \crefname{subsection}{unit}{units} % label to be used in cross-references

\begin{document} \section{Hello} \label{sec:hello} \subsection{World} \label{sec:world} \subsection{Solar System} \label{sec:system} \subsection{Galaxy} \label{sec:galaxy} \subsection{Universe} \label{sec:universe}

As required, the first subsection header says \textbf{Unit I@. World}.

\medskip \noindent As shown in \Cref{sec:world,sec:galaxy,sec:universe} of \Cref{sec:hello}, \dots \end{document}

Mico
  • 506,678
  • +1: Amazing! Is "@" something that should be familiar to a normal TeX user? – Dr. Manuel Kuehner Jan 23 '21 at 18:34
  • 1
    @Dr.ManuelKuehner - The \@ directive informs TeX that the following . particle should be treated as a sentence-ending punctuation mark. The use of \@ is admittedly optional, but I thought it provides a nice aesthetic touch here, since it provides for just a little bit of visual "breathing space" between the uppercase-Roman numeral and the uppercase letter that starts off the section's text label. (Of course, if \frenchspacing is in effect, then \@ has no effect, but it doesn't hurt either.) – Mico Jan 23 '21 at 20:42