13

How can i check if the value in \thechapter or \value{chapter} is a letter or a number? That way i could identify if the counter is referring to a normal Chapter or an Appendix.

lockstep
  • 250,273
Pedro
  • 267

1 Answers1

14

if you're using the book.cls, you can check this way:

\makeatletter
\ifx\@chapapp\appendixname
  <whatever you want to do for an appendix>
\else <whatever you want to do for a regular chapter>
\fi
\makeatother

if you're using a different class, look for how \chaptername and \appendixname are used and adapt the above code appropriately.

Edit:

The question Is there an "\if" command that determines if a command has been issued? provides an approach that can be used if \@chapappis not defined by the class.

  • Thank you. Didn't knew about \@chapapp! Very useful – Pedro May 28 '12 at 18:05
  • This seems failed on texlive2022. – Syvshc May 31 '22 at 08:54
  • I found a newer one https://tex.stackexchange.com/questions/233238/is-there-an-if-command-that-determines-if-a-command-has-been-issued – Syvshc May 31 '22 at 11:57
  • @Syvshc -- Thanks for the pointer. This depends heavily on what document class is used, and the answers to that question make different assumptions. Pointer added to this answer. – barbara beeton May 31 '22 at 13:25