Fonts & Character SetsSetting up a heading: KOMA-script, MakeUppercase, autodot, ...

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
Christoph
Posts: 29
Joined: Tue Mar 22, 2022 5:22 pm

Setting up a heading: KOMA-script, MakeUppercase, autodot, ...

Post by Christoph »

Hello

This Topic is complementary to my first forum topic:
https://latex.org/forum/viewtopic.php?f=48&t=34795
Till now I´ve been mainly working with KOMA-script and it´s documentation scrguide.

Here are the adjustments I´ve done before:

Code: Select all

\documentclass[
%	paper=a4,
fontsize=12pt,
]{scrreprt}

\usepackage{lipsum}
\usepackage{tgadventor}

\renewcommand*\familydefault{\sfdefault} % Only if the base font of the document is to be sans serif
\usepackage[T1]{fontenc}

%% NEW ADJUSTMENTS TO THE HEADINGS 
%\newcommand*{\chapterformat}{
%	\thechapter\autodot\enskip}
%%END NEW ADJUSTMENTS TO THE HEADINGS


\usepackage{xcolor}
\setlength{\fboxsep}{10pt}
\makeatletter
\renewcommand{\chapterlinesformat}[3]{%
	\fcolorbox{black}{lightgray}{%
		%	\framebox{
			\parbox{\dimexpr\linewidth-5
				\fboxrule-2\fboxsep}{%
				\@hangfrom{#2}#3%
			}%
		}%
	}%}
\makeatother

\begin{document}
	
\chapter{Allemeine Anaben}
\lipsum[2]
\section{Konsensinhaber}
\lipsum[5]
\subsection{Subsection}
\lipsum[3]
\subsubsection{Subsubsection}

\end{document}
My target ist to set up the chapter´s heading the following way:
- The number should be "1. First Chapter" - also in section, subsection, subsubsection...
- The chaptertitle should use Uppercase letters or kapitälchen

As I´ve detected there are the following entries predefined for the command "\chapterformat"

Code: Select all

\newcommand*{\chapterformat}{%
\thechapter\autodot\enskip}

To achieve the dot at the end of the number I´would simply replace "\autodot" by "."
But I get the Error: "Command \chapterformat already defined. \thechapter\autodot\enskip}"

To understand the thing behind the surface:
What´s the difference between "\newcommand" and "\newcommand*"?
What does the command "\autodot" do by default?
Do you have some general tipps how to search for such answers - to prevent the need of a forum Topic next time?


To achieve the Uppercase letters in the chapter´s heading I´ve added tho following code:

Code: Select all

%% NEW ADJUSTMENTS TO THE HEADINGS 
\addtokomafont{chapter}{\MakeUppercase}
%%END NEW ADJUSTMENTS TO THE HEADINGS
Which results in the following Error:
"Package xcolor Error: Undefined color `BLACK'. \chapter{Allemeine Anaben}"

Thanks and best regards Christoph
Last edited by Christoph on Fri Mar 25, 2022 11:40 am, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Setting up a heading: KOMA-script, MakeUppercase, autodot, ...

Post by Stefan Kottwitz »

Hi Christoph,

\newcommand* is explained here: newcommand vs newcommand*.

\autodot is explained in the KOMA-Script manual in section 3.16 Gliederung, in the middle of that long section.

Forum search: at the top right we have a search field, right of it there'a an "Advanced Search" button, with a gear symbol. Don't worry if you open a topic about something that we talked about earlier - at least I will not complain. ;-) LaTeX changes over the years anyway, so a fresh topic may be good, and we are a discussion forum anyway and like to talk about LaTeX.

Regarding that error message: as the command already exists, use \renewcommand* instead of \newcommand*.

And by the way we have German language partner forums if you like that too: TeXwelt.de for specific questions (question and answer format, topic tagging, ...), goLaTeX.de for more free LaTeX discussions, questions, threads.

Stefan
LaTeX.org admin
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Setting up a heading: KOMA-script, MakeUppercase, autodot, ...

Post by Stefan Kottwitz »

Hi Christoph,

the xcolor error is caused by the \MakeUppercase command with the color black inside; it's changed to BLACK. It's in your fcolorbox.

Remove that \MakeUppercase command and put it inside the box, so it only affects the heading text:

Code: Select all

\renewcommand{\chapterlinesformat}[3]{%
	\fcolorbox{black}{lightgray}{%
		%	\framebox{
			\parbox{\dimexpr\linewidth-5
				\fboxrule-2\fboxsep}{%
				\@hangfrom{#2}\MakeUppercase{#3}%
			}%
		}%
	}%}
Stefan
LaTeX.org admin
Christoph
Posts: 29
Joined: Tue Mar 22, 2022 5:22 pm

Setting up a heading: KOMA-script, MakeUppercase, autodot, ...

Post by Christoph »

Thanks! DONE!
I´ll open a new Topic
Post Reply