# Changing the section format

Consider the \section{abc}

the output will be like

1. abc


how can I change the '.' to '-' or vice versa. i.e.

2- abc

• This is not necessarily true. What class are you using? A naive hack for the article class would be \makeatletter\renewcommand\thesection{\@arabic\c@section-}\makeatother ... but look at what that does to the Table of Contents (or if you also have subsections). It is therefore best to provide a minimal example (or here). – jon Jun 18 '13 at 5:58
• I think the package titlesec can be of help. – koppor Jan 25 '18 at 6:52

Redefining \thesection doesn't help, because this will give wrong results when referencing a section number.

A “package free” solution is to access the \@seccntformat feature:

\documentclass{article}
\makeatletter
\renewcommand{\@seccntformat}[1]{%
\csname the#1\endcsname\ --\ }
\makeatletter

\begin{document}
\section{Introduction}\label{sec:intro}

We're in section~\ref{sec:intro}.
\end{document}


You can use

\renewcommand{\thesection}{\arabic{section}-}


for that specific purpose. Note that you could also use roman, Roman, alph or Alph instead of arabic, and you can also customize further by adding \thechapter, for instance.

• Unfortunately this is wrong. References to sections will contain the dash, which is certainly unwanted. – egreg Jun 18 '13 at 8:31

Without an additional knowledge about usage it may be simply (see probably corrected spacing):

\documentclass{article}

\def\thesection{\arabic{section}--\hspace{-1em}}
\begin{document}

\section{First}

\end{document}


• Did you try doing \ref{sec:whatever} when the label is linked to a section? – egreg Jun 18 '13 at 8:25
• @egreg I know, that ALL should be labelled "Achtung! Minen!", but without the requested usage I choose such a solution. – Przemysław Scherwentke Jun 18 '13 at 8:36