4

Consider the \section{abc}

the output will be like

1. abc

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

2- abc
Torbjørn T.
  • 206,688
Mamal
  • 419
  • 3
    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 05:58
  • I think the package titlesec can be of help. – koppor Jan 25 '18 at 06:52

3 Answers3

15

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}

enter image description here

egreg
  • 1,121,712
2

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.

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

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}

enter image description here