2

I’m looking for a way (or a package) to change or control the formatting of the numbers of a section. By formatting, I mean the fonts and the like, not the formatting of the number

As far as I can see, the only way seems to redefine the @sect command, for example. But I’d prefer to avoid this: as you can see, I’m not a TeX expert.

5
  • 2
    There are the packages sectsty and titlesec. The package titlesec is more complicated then sectsty, but can do more. If I understand your question correctly, I think sectsty would be sufficient for you. Nov 28, 2016 at 16:34
  • 2
    Could you be more precise about what changes you have in mind? Surely \@sect is not the macro to act on, anyway.
    – egreg
    Nov 28, 2016 at 16:38
  • 1
    Which class are you using? There are some classes with predefined styles, see e.g. ftp.dante.de/tex-archive/info/MemoirChapStyles/… Nov 28, 2016 at 16:55
  • @egreg I’d like to change, say, the typeface of the number.
    – giorgio_v
    Nov 30, 2016 at 7:55
  • @PietvanOostrum Thanks for the suggestions. I’ll try them out.
    – giorgio_v
    Nov 30, 2016 at 7:56

1 Answer 1

2

For extensive changes to the sectional titles, titlesec is the package to go. For less extensive changes, you can go with internals.

\documentclass{article}

\makeatletter
\renewcommand{\@seccntformat}[1]{%
  \begingroup
  \@nameuse{additional@cntformat#1}%
  {\@nameuse{the#1}}%
  \endgroup
  \quad
}
\newcommand{\setformat}[2]{%
  \@namedef{additional@cntformat#1}{#2}%
}
\makeatother

\setformat{section}{\itshape}
\setformat{subsection}{\normalfont}
\setformat{subsubsection}{\fbox}

\begin{document}

\section{Example of section}

\subsection{Example of subsection}

\subsubsection{Example of subsubsection}

\end{document}

The last token in the second argument to \setformat can take an argument, like in the example for \subsubsection.

enter image description here

You must log in to answer this question.

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