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}
5
  • Is there a chance that you'll need to cross-reference multiple subsections and would like the cross-reference to look like "... as discussed in Units II, III, and IV, ..."? Please advise. – Mico Jan 23 at 6:37
  • @mico You overachiever! :) – Dr. Manuel Kuehner Jan 23 at 9:49
  • 1
    @Dr.ManuelKuehner - Your answer is fine. I believe I was the first one to upvote it. :-) – Mico Jan 23 at 10:43
  • @BaRud Is your problem solved? If yes, then consider accepting one of the provided answers. – Dr. Manuel Kuehner Jan 24 at 1:42
  • Oh... I upvoted your answer, missed to accept it. – BaRud Jan 24 at 7:18
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}
2
  • +1: Amazing! Is "\@" something that should be familiar to a normal TeX user? – Dr. Manuel Kuehner Jan 23 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 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.