2

I would like to add a dot after the number of each section (including chapters) in a report class document. I'd prefer not to have to resort to Koma-script solutions. There are a lot of other good ideas here: How to add a dot after the section number? but either they don't take care of the problem that cross-referencing comes with a dot as well, or they include only sections and below and not chapters. My Latex knowledge is too limited to generalize Mico's solution by myself, but it should be straightforward (seriously this question should be a comment to these posts, but I'm not allowed to comment :) ).

Alternatively, one could use the fix proposed here: Remove dot-after-number in figure captions while keeping the dot in chapter/section captions with label/ref instead of figure... So see, I'm pretty close but still missing something!

Ella
  • 23
  • 1
    Welcome to tex.sx. – barbara beeton Jun 19 '19 at 19:59
  • Did you try the titlesec solution? – Bernard Jun 19 '19 at 23:19
  • @Bernard The titlesec solution worked fine except for chapters, plus there is a conflict with fancyhdr apparently... I guess these two are redundant. – Ella Jun 20 '19 at 16:55
  • Could post a minimal example illustrating the problem? As to fancyhdr, a very nice titleps comes with titlesec, and it can easily define or redefine page headers and footers styles. – Bernard Jun 20 '19 at 17:24
  • Actually I wasn't using titlesec and fancyhdr together on purpose; the latter was part of a thesis style I just blindly implemented. It turns out calling titlesec after fancyhdr makes it work alright, in case anyone can benefit from that. Strangely it does not add a dot for chapters, but I just put one by hand in the chapter header as well as in the page header in the style file. Thanks all! I'm validating the answer anyway since it did answer my question as it was. – Ella Jun 21 '19 at 13:58

1 Answers1

3
\documentclass{report}

\usepackage{etoolbox}
\makeatletter
\patchcmd\@makechapterhead{\thechapter}{\thechapter.}{}{\fail}
\patchcmd\@seccntformat{\csname the#1\endcsname}{\csname the#1\endcsname.}{}{\fail}
\makeatother
\begin{document}
\chapter{chapter}\label{chap}
\section{section}\label{sec}
\ref{chap}, \ref{sec}
\end{document}
Ulrike Fischer
  • 327,261
  • Thanks, would work great if not for fancyhdr... – Ella Jun 20 '19 at 17:10
  • Well you didn't add an example and your question doesn't mention fancyhdr. If you have additional requirements, ask a new question and this time add a sensible example to avoid that people waste their time to answer the wrong question. – Ulrike Fischer Jun 20 '19 at 17:17