A journal, which I intend to submit to, asks that section headings are preceded with <heading number ...>. So I used this answer to create my custom prefix to the section headings:

\renewcommand\thesection{\textless heading level 1\textgreater \ \arabic{section}}
\renewcommand\thesubsection{\textless heading level 2\textgreater \ \arabic{section}.\arabic{subsection}}
\renewcommand\thesubsubsection{\textless heading level 3\textgreater \ \arabic{section}.\arabic{subsection}.\arabic{subsubsection}}

This works very well for the headers, but when I \cite{ch:foo} the reference appears as "<heading level 2> 2.3", which I would like to avoid. The second answer on the question gives an alternative solution, which seems to me (as a Latex rookie) more of a hack:

\def\section{\@startsection{section}{1}{\z@ }%
  {-3.5ex\@plus -1ex\@minus -.2ex}{2.3ex \@plus .2ex}%
  {\noindent\normalfont \Large \bfseries Prefix\ }%

Can you propose a better way?

1 Answer 1


Here is a solution

\patchcmd{\@sect}{\@seccntformat}{heading level #2 \@seccntformat}{}{}


enter image description here

  • Thank you very much. Not sure what this does, but it works!
    – n1000
    Commented Jul 27, 2016 at 18:11
  • @n1000 \(sub...)section use internal \@startsection which use internal \@sect which use internal \@seccntformat that format the number of (sub...)section here we redefine \@sect by adding the prefix just before \@seccntformat using\patchcmd for shortness.
    – touhami
    Commented Jul 27, 2016 at 19:13
  • Sorry to bother, but do you have any clue why this will not work when I \usepackage{hyperref}?
    – n1000
    Commented Jul 27, 2016 at 20:12
  • 1
    this is because hyperref redefine some internals command to do the job. In this case just load hyperref after you make the change.
    – touhami
    Commented Jul 27, 2016 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .