I want to change the commands of the article/ book class and want to know how sections, especially in the article class but also in the book class, are defined.

I think it is something like this?:

                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%

I want to alter them a little bit and add some commands using \renewcommand in a class (.cls) I'm currently writing. Where can I find the other section definitions? Can someone provide a link or the code in an answer?

  • 1
    That's the definition of \subsection. All of \(sub(sub))section and \(sub)paragraph have similar definitions (in the LaTeX standard classes, at least), which depend on \@startsection. \chapter and \part, in classes which have them, are different. Here's a description of how \@startsection works, if that's what you're looking for: tex.stackexchange.com/a/509474/134574. What exactly do you want to change in the sectioning commands? Nov 18, 2019 at 17:44
  • @PhelypeOleinik I want to add a command I define, which I call \sectioncolor, \subsectioncolor etc. to the last line, so that I can use another command; \setsectioncolor{blue} before \begin{document}, and then all section headlines will appear blue.
    – Vebjorn
    Nov 18, 2019 at 17:55
  • You can find the definition of \@startsection in source2e.pdf (CTAN). The tricky bit is that it has 7 arguments. The first five are shown and the last two are stolen from \section etc. Nov 18, 2019 at 18:46
  • @JohnKormylo yes, but I want to know how \section{} is defined specifically in the article class so it will not appear different when I \renew it.
    – Vebjorn
    Nov 18, 2019 at 18:58
  • 1
    It would be easier to do that with titlesec.
    – Bernard
    Nov 18, 2019 at 18:59

2 Answers 2


Along these lines?


                                 {-3.25ex\@plus -1ex \@minus -.2ex}%
                                 {1.5ex \@plus .2ex}%

but taking due account of how coloring works.

For the code for chapters look in the code for the appropriate class (book, report, memoir, etc)

  • Yes. That is exactly what I want to do. I only need to figure out how \section and \subsubsection is defined.
    – Vebjorn
    Nov 18, 2019 at 18:55
  • @Vebjorn `kpsewhere article.cls' gives you the path to the file.
    – campa
    Nov 18, 2019 at 19:22

I found the whole article.cls file here (where the sections is defined): https://www.tug.org/svn/texlive/trunk/Master/texmf-dist/tex/latex/base/article.cls?view=co

I do not use a downloaded version of LaTeX, only online (Overleaf) so the command kpsewhere article.cls is no use because the file is not stored on my computer.

You must log in to answer this question.

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