Text FormattingDot after Number in Heading

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
jgaspard
Posts: 20
Joined: Tue Aug 19, 2008 4:16 pm

Dot after Number in Heading

Post by jgaspard »

Hi there!

A short, simple question: how can I add a dot in the section numbering? I have "1.1" and I want to have "1.1."

Thank you very much!

Bye

Jeffrey

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Dot after Number in Heading

Post by Stefan Kottwitz »

Hi,

with a KOMA-class you could use the option numbers=enddot, or, in case of older KOMA-classes, pointednumbers.

With LaTeX standard classes you could redefine \thesection or just add a dot by

Code: Select all

\makeatletter
\g@addto@macro\thesection.
\makeatother
Stefan
LaTeX.org admin
jgaspard
Posts: 20
Joined: Tue Aug 19, 2008 4:16 pm

Re: Dot after Number in Heading

Post by jgaspard »

Thank you!

Best regards,

Jeff.
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Dot after Number in Heading

Post by gmedina »

Hi,
Stefan_K wrote:...
With LaTeX standard classes you could redefine \thesection or just add a dot by

Code: Select all

\makeatletter
\g@addto@macro\thesection.
\makeatother
Stefan
But this will produce undesired results in lower sectional units, as the following simple example demonstrates:

Code: Select all

\documentclass{book}

\makeatletter
  \g@addto@macro\thesection.
\makeatother

\setcounter{secnumdepth}{5}

\begin{document}

\chapter{Test chapter}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\paragraph{Test paragraph}
\subparagraph{Test subparagraph}

\end{document}
To avoid this situation, I would prefer a redefinition of all the commands associated to the sectioning counters, as the following example illustrates:

Code: Select all

\documentclass{book}

\renewcommand\thesection{\thechapter.\arabic{section}.}
\renewcommand\thesubsection{\thesection\arabic{subsection}.}
\renewcommand\thesubsubsection{\thesubsection\arabic{subsubsection}.}
\renewcommand\theparagraph{\thesubsubsection\arabic{paragraph}.}
\renewcommand\thesubparagraph{\theparagraph\arabic{subparagraph}.}

\setcounter{secnumdepth}{5}

\begin{document}

\chapter{Test chapter}
\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\paragraph{Test paragraph}
\subparagraph{Test subparagraph}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
rf
Posts: 21
Joined: Mon Jul 20, 2009 5:27 pm

Dot after Number in Heading

Post by rf »

jgaspard wrote:A short, simple question: how can I add a dot in the section numbering? I have "1.1" and I want to have "1.1."
Us it appropriate to quote the FAQ here? If so, take a look at this.

http://www.tex.ac.uk/cgi-bin/texfaq2htm ... =seccntfmt

Otherwise, please ignore that, and accept my apologies.
krasnal1988
Posts: 8
Joined: Tue May 10, 2011 10:31 pm

Dot after Number in Heading

Post by krasnal1988 »

Hi!

I have small problem with numbering. Of course I use code from this page.

Code: Select all

\def\@seccntformat#1{\csname the#1\endcsname.\quad}
\def\numberline#1{\hb@xt@\@tempdima{#1\if&#1&\else.\fi\hfil}}
In my document I use algorithm environment. Every algorithm has number of section and number of algorithm eg. "Algorithm 3.1". I want add dot after last number eg. "Algorithm 3.1.". If I use

Code: Select all

\renewcommand{\thealgorithm}{\thesection.{\arabic{algorithm}.}}
I'll get what i want, but in list of algorithms i have double dot ("3.1.. Algorithm of...")

How to solve this problem?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10320
Joined: Mon Mar 10, 2008 9:44 pm

Re: Dot after Number in Heading

Post by Stefan Kottwitz »

Hi krasnal1988,

welcome to the board!

Generally it would be good to open a new thread for a new question, so more people may read your question. A link to an earlier question would be good of course. This thread is already marked as solved.

I would split the thread later on.

Regarding your problem: numbering and dots may be determined by document class, class options, packages and settings, so it would be good if you would post your complete preamble.

Stefan
LaTeX.org admin
Arezou
Posts: 2
Joined: Sun Jun 30, 2013 11:45 pm

Dot after Number in Heading

Post by Arezou »

Hi,

I'm new to LaTeX and your question was mine too. Always searching for the shortest and simplest answer, I should tell that Stefan's answer is the shortest one with one small modification.

Code: Select all

\makeatletter
\g@addto@macro\thesubsection.
\makeatother
Now by changing \thesection to \thesubsection you will get the desired result!
Post Reply