Page LayoutReduce horizontal space between section title and numbering

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
larschrjensen
Posts: 10
Joined: Thu Dec 29, 2011 3:30 pm

Reduce horizontal space between section title and numbering

Post by larschrjensen »

Hi,

Is it possible to reduce the horizontal space between the section title and section numbering? My section header looks like this:

1 Header

and I'd like something like this:

1. Header

Best regards,
Lars

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

Re: Reduce horizontal space between section title and number

Post by Stefan Kottwitz »

Hi Lars,

welcome to the board!

The answer depends on the document class you are using. Which one is it?

Stefan
LaTeX.org admin
larschrjensen
Posts: 10
Joined: Thu Dec 29, 2011 3:30 pm

Re: Reduce horizontal space between section title and number

Post by larschrjensen »

Thank you Stefan,

The documentclass I use is the report class.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Reduce horizontal space between section title and numbering

Post by Stefan Kottwitz »

With the titlesec package:

Code: Select all

\documentclass{report}
\usepackage{titlesec}
\titleformat{\section}
  {\normalfont\Large\bfseries}{\thesection}{0.2em}{}
\begin{document}
\chapter{One}
\section{Header}
\end{document}
Customize the 0.2em if you like, originally it's 1em.

Stefan
LaTeX.org admin
larschrjensen
Posts: 10
Joined: Thu Dec 29, 2011 3:30 pm

Re: Reduce horizontal space between section title and number

Post by larschrjensen »

Thank you very much!

Texmaker marks \titleformat and \thesection as unrecognized commands but it works wonderfully.

Is there any way to do the same with the table of contents? I have called it by invoking \tableofcontents ?

Best regards,
Lars
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

Reduce horizontal space between section title and numbering

Post by Stefan Kottwitz »

larschrjensen wrote:Texmaker marks \titleformat and \thesection as unrecognized commands but it works wonderfully.
Texmaker doesn't know all LaTeX packages, and titlesec is an extension package, so that's normal.
larschrjensen wrote:Is there any way to do the same with the table of contents? I have called it by invoking \tableofcontents?
Probably with titletoc, which is a companion to titlesec for designing the table of contents. Or use tocloft.

Stefan
LaTeX.org admin
larschrjensen
Posts: 10
Joined: Thu Dec 29, 2011 3:30 pm

Re: Reduce horizontal space between section title and number

Post by larschrjensen »

Thank you very much for your help. It was very helpful.

Best regards,
Lars
erwann
Posts: 75
Joined: Thu Aug 25, 2016 2:24 am

Reduce horizontal space between section title and numbering

Post by erwann »

Stefan Kottwitz wrote:With the titlesec package:

Code: Select all

\titleformat{\section}
  {\normalfont\Large\bfseries}{\thesection}{0.2em}{}
Customize the 0.2em if you like, originally it's 1em.

Stefan
Is an empty field = default? And also, where are the default values to be found?
x_86 / Linux Mint 18.3 / texlive 2015.20160320-1ubuntu0.1 / TeXworks 0.5r1361 (Debian)
erwann
Posts: 75
Joined: Thu Aug 25, 2016 2:24 am

Reduce horizontal space between section title and numbering

Post by erwann »

Answer to m/s: no, an empty field != package's default. I tried. Would it be such a hardship to wrap this with a keyval command to be able to change only a subset of the parameters?

Code: Select all

\titleformat{〈command 〉}[〈shape〉]{〈format〉}{〈label 〉}{〈sep〉}{〈before-code〉}[〈after-code〉]
Manual: https://mirror.las.iastate.edu/tex-arch ... tlesec.pdf
x_86 / Linux Mint 18.3 / texlive 2015.20160320-1ubuntu0.1 / TeXworks 0.5r1361 (Debian)
Post Reply