[Tex/LaTex] Changing the section format

formattingsectioning

Consider the \section{abc}

the output will be like

1. abc

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

2- abc

Best Answer

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

Related Question