0

In order to illustrate a large chapter number on the beginning of each chapter, I created a tikz environment and added it to the CLS file like this:

\begin{tikzpicture}
    ........
        \node[anchor=north west, inner sep=0pt, ] at (0.905\textwidth,1.42) {\sffamily\fontsize{130}{150}\selectfont \color{gray}\thechapter};
    ........
\end{tikzpicture}

By this way, the \thechapter numbering appears as a "0" to the Contents, List of Tables and List of Figures, which is undesirable. I want numbering to begin from the first Chapter as "1" and so on. So I added an \if statement like this:

\begin{tikzpicture}
    ........
    \ifnum\value{\thechapter}>0{
        \node[anchor=north west, inner sep=0pt, ] at (0.905\textwidth,1.42) {\sffamily\fontsize{130}{150}\selectfont \color{gray}\thechapter};
    \else{};
    \fi;
    ........
\end{tikzpicture}

but the \thechapter numbering totally disappeared, so obviously it seems that I do not use the \if statement correctly. So, which is the right way to use the \if statement in this case?

Any thoughts would be appreciated.

1 Answers1

5

The command \value wants as its argument the name of a counter, so you want

\ifnum\value{chapter}>0
  \node[anchor=north west, inner sep=0pt, ] at (0.905\textwidth,1.42) {\sffamily\fontsize{130}{150}\selectfont \color{gray}\thechapter};
\fi

No braces around the texts for true or false (unless you do want them, for instance in order to localize a font change). The \else branch can be omitted if empty.

You might find elsewhere something like \ifnum\thechapter>0, but this is wrong, because \thechapter will provide the current representation of the chapter counter, which may or may not be usable in this context. Assuming it isn't is safer; that's why \value{chapter} is provided: it points to the “abstract” value, independent of the representation.

egreg
  • 1,121,712