9

Consider a chapter in a french book defined by:

\chapter{Blablabla}

It will generate the output:

Chapitre I : Blablabla

Then, we have the following variables:

  • \chaptername corresponds to Chapitre
  • \thechapter corresponds to I

Question: what is the variable containing the chapter title Blablabla?

6
  • 2
    Strictly speaking, these are macros, not variables. But, in any event, this depends on the document class in use, so please provide a minimal working example. May 4, 2015 at 1:49
  • @PaulGessler In the standard classes, there is no such macro, is there? \leftmark includes the name of the chapter but it also includes the other parts of the mark. Or am I overlooking something?
    – cfr
    May 4, 2015 at 1:51
  • 1
    @cfr You didn't miss anything :-) But it can be given a name if need be.
    – user11232
    May 4, 2015 at 1:52
  • @Vincent You really should look at titleps and titlesec as Bernard suggested.
    – cfr
    May 4, 2015 at 2:03
  • What about \@title{}?
    – Sigur
    May 4, 2015 at 5:45

2 Answers 2

14

Document classes

The standard classes report and book and the KOMA-Script classes scrreprt and scrbook do not store the chapter title in macros.

Class memoir uses three internal macros for the chapter title and its variations for the table of contents and the header lines:

\chapter[title in table of contents][title in header line]{title in body}

Then the internal macros contain:

\f@rtoc -> title in table of contents
\f@rhdr -> title in header line
\f@rbdy -> title in body

Packages

There are packages, which support to reference chapter titles.

  • Package nameref:

    \chapter[title in table of contents]{title in body}
    \label{chap:label}
    

    Then \nameref{chap:label} yields "title in table of contents". The name is stored in the internal macro \@currentlabelname (until it is overwritten by the next title).

  • Package titleref:

    \chapter[title in table of contents]{title in body}
    \label{chap:label}
    

    Then \titleref{chap:label} gives "title in table of contents". The name is stored in the internal macro \TR@currentTitle (until overwritten).

  • Package zref-titleref:

    \chapter[title in table of contents]{title in body}
    \zlabel{chap:label}% \zref@label or \zlabel with package zref-user
    

    Then "title in table of contents" is stored by \zref@titleref@setcurrent in property title in macro \zref@titleref@current.

2
  • What is the name of the file with the manual of zref-titleref?
    – Keks Dose
    May 4, 2015 at 12:49
  • 1
    @KeksDose zref is the main project. May 4, 2015 at 12:49
-1

There seems to be a terrible lack of modularity and compositionality in all this. Here's my situation: I am formatting a book, which has the chapter title without the chapter number as the heading on odd-numbered pages. (This is, incidentally, a very common feature in book designs: I had a quick look at books on my bookshelf and lots of them do this). One would think that it would be handy tohave a) a variable containing the chapter number, and b) a variable containing the text of the chapter name without the chapter number. And one would also think that any formatting could be applied to these variables after they had been defined, and that one would have a clear distinction of levels between the definitions of the data (i.e. chapter number, chapter name) and the formatting applied to them in a particular design. I may be missing the obvious, but is there a simple way of doing this, using the LaTeX standard classes?

2
  • 3
    Welcome to the TeX - LaTeX Stack Exchange. This should be a new question or comment, not an answer.
    – plante
    Dec 6, 2021 at 12:49
  • 1
    If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – Mensch
    Dec 6, 2021 at 13:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.