[Tex/LaTex] Access the chapter/section number and the chapter/section label through variables

countersnumberingsectioning

Often I find myself in the situation that I'd like to design how chapters and sections look. I know there are packages that help to design such things, but non of them seems to give me the option to use the chapter/section number and the label as variables (like #1, #2).

Stefan has done something close to what I want in his blog using titlesec, but I was wondering:

Is there a pure LaTeX way of accessing the number and label of chapter/sections and use those in variables while I design a pagestyle?

Best Answer

All the sectioning commands are in class (book, article report etc). Search in your distribution and look for book.cls.

They are quite lengthy and they are not in one place. For example all the "name" commands can be found towards the end of the class in one place.

Here is a minimal as to how to change some of the parameters.

\documentclass[oneside]{book}
\makeatletter
\renewcommand\chaptername{chapteris}
\renewcommand \thechapter {\@Roman\c@chapter}

\renewcommand\section{\@startsection{section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\large\scshape}}

\newcommand\sectionis{\@startsection{section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\large\scshape}}

\renewcommand\appendix{\par
  \renewcommand\chaptername{Appendixis}
  \setcounter{chapter}{0}
  \setcounter{section}{0}
  \gdef\@chapaa{\appendixname}
  \gdef\thechapter{\@roman\c@chapter}
 }

\makeatother
\begin{document}
  \tableofcontents
  \chapter{My First Chapter}
  \section{One}
  \sectionis{Two}
  \chapter{My Second Chapter}
  \appendix
  \chapter{First Appendix}
  \chapter{Second Appendix}
\end{document}