2

I have a problem with the numbers added to the chapters of my document: There is no dot after the number, e. g. "2 Theory" instead of "2. Theory". I tried adding a dot before the chapter title but then it looks like "2 . Theory". I also tried \documentclass[a4paper,11pt,numbers=endperiod]{scrreprt} and %\renewcommand{\thechapter}{\arabic{chapter}.} but both add a dot after every number, even "1.1. Title" where I want "1.1 Title".

My document looks like this:

    \documentclass[a4paper,11pt]{scrreprt}

    \usepackage[utf8]{inputenc}
    \usepackage[ngerman]{babel}
    \usepackage[T1]{fontenc}
    \graphicspath{{img/}}
    \usepackage{fancyhdr}
    \usepackage{lmodern}
    \usepackage[T1]{fontenc}
    \usepackage{caption}
     \usepackage{textcomp}

    \addtokomafont{section}{\small}
    \addtokomafont{subsection}{\small}
    \addtokomafont{subsubsection}{\small}


\begin{document}
\include{theory}
\include{experiment}
\end{document}
RBG
  • 21

3 Answers3

4

If sections, subsections etc. should not get a dot after the number, use option numbers=noenddot. One possibility to add the dot after chapter number is

\usepackage{xpatch}
\xpatchcmd\chapterformat{\autodot}{.}{}{\PatchFailed}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithdot
]{chapter}{chapter}
\newcommand*\entrynumberwithdot[1]{\def\autodot{.}#1}

Example (with additional remarks):

\documentclass[
  %a4paper,11pt,% default
  numbers=noenddot% default value: autoenddot
]{scrreprt}
%\usepackage[utf8]{inputenc}% needed with older TeX distributions
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage{graphicx}% <- added
\graphicspath{{img/}}
\usepackage{fancyhdr}% it is suggested to use package scrlayer-scrheadings
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage{caption}% maybe you can use KOMA-Script commands?
\usepackage{textcomp}

\RedeclareSectionCommands[
  font=\small
]{section,subsection,subsubsection}


\usepackage{xpatch}
\xpatchcmd\chapterformat{\autodot}{.}{}{\PatchFailed}

\DeclareTOCStyleEntry[
  entrynumberformat=\entrynumberwithdot
]{chapter}{chapter}
\newcommand*\entrynumberwithdot[1]{\def\autodot{.}#1}

\usepackage{blindtext}% only for dummy text in the MWE

\begin{document}
\tableofcontents
\Blinddocument
\end{document}
esdd
  • 85,675
1

you can use the koma option

numbers=enddot

so the first line will be

  \documentclass[a4paper,11pt,numbers=enddot]{scrreprt}

Edit:

This will set points also after section numbers.

You may want to go with: Remove last dot in title numbering

This is a solution specifically for KOMA-Script

Philipp
  • 222
  • 1
    As the OP already mentioned in her question, this will also add a period after the section number which seems to be undesired. " I also tried \documentclass[a4paper,11pt,numbers=endperiod]{scrreprt}[...] add a dot after every number, even "1.1. Title" where I want "1.1 Title". " – leandriis Sep 29 '19 at 10:51
0

This should work in every documentclass and it is based on my answer here

\documentclass[a4paper,11pt]{scrreprt}

    \usepackage[utf8]{inputenc}
    \usepackage[ngerman]{babel}
    \usepackage[T1]{fontenc}
    %\graphicspath{{img/}}
    \usepackage{fancyhdr}
    \usepackage{lmodern}
    \usepackage[T1]{fontenc}
    \usepackage{caption}
     \usepackage{textcomp}

    \addtokomafont{section}{\small}
    \addtokomafont{subsection}{\small}
    \addtokomafont{subsubsection}{\small}

\let\oldchapter\chapter
\makeatletter
\def\chapter{%
\def\thechapter{\arabic{chapter}.}%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}      
\def\@StarredWith[#1]#2{%
\oldchapter*{#2}%
\def\thechapter{\arabic{chapter}}%
}
\def\@StarredWithout#1{
\oldchapter*{#1}%
\def\thechapter{\arabic{chapter}}%
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldchapter[#1]{#2}%
\def\thechapter{\arabic{chapter}}%
}
\def\@nonStarredWithout#1{%
\oldchapter{#1}%
\def\thechapter{\arabic{chapter}}%
}
\makeatother

\usepackage{blindtext}% only for dummy text in the MWE
\begin{document}
\tableofcontents
\Blinddocument
\end{document}

Adding in order to be able to help people with other document classes or even for the OP's request if he would like to be able to change documentclass later.

koleygr
  • 20,105
  • 1
    Then chapters in appendix also get arabic numbers. Additionally the dot is in references, if you use \label{...} and \ref{...} for a chapter. – esdd Sep 29 '19 at 12:43
  • Thanks for the comment @esdd ... You are right ... Could take care of the first easily ... but not of the second (not so easy but with some effort -as far as I can think right now- ...) Anyway ... thanks! Useful comment ... and more useful answer! – koleygr Sep 29 '19 at 12:56