5

I have made a custom chapter head style and I would like to use it even with table of content.

so for this I have:

\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{arrayjob}

\title{demo}


\newarray\dnaletters
\readarray{dnaletters}{A&C&G&T}
\colorlet{Random1}{cyan}
\colorlet{Random2}{yellow}
\colorlet{Random3}{red}
\colorlet{Random4}{green}

\makeatletter
    \makechapterstyle{thesisStyle}{
        \renewcommand{\chapternamenum}{}
        \renewcommand{\chapnumfont}{\normalfont\Huge\bfseries}
        \renewcommand{\printchapternum}{}
        \renewcommand{\printchaptername}{}
        \renewcommand\printchaptertitle[1]{
            \begin{tikzpicture}[remember picture,overlay,shift={(current page.north west)},yshift=-3cm]
                \path[fill=Black] (0,0) rectangle(\paperwidth,3cm);
                \foreach \x in {0,1, ..., 70}{
                    \foreach \y in {0, ...,7} 
                        \pgfmathsetmacro\Random{random(1,4)}
                    \node[draw=none,color=Random\Random,anchor=south west,font=\tiny,xshift=-.05cm] at (\x*.3cm,\y*.33cm) {\dnaletters(\Random)};
                };
                \node[anchor=east,xshift=.9\paperwidth,rectangle, rounded corners=20pt,inner sep=11pt, fill=MidnightBlue] {
                    \ifnum\value{chapter}>\value{0}
                        \normalfont\Huge\bfseries\color{white}\thechapter|~##1
                    \else
                        \normalfont\Huge\bfseries\color{white}##1
                    \fi
                };
            \end{tikzpicture}
        }
        \renewcommand{\afterchapternum}{}
    }
\makeatother

\headstyles{thesisStyle}
\chapterstyle{thesisStyle}

\begin{document}

\tableofcontents
\chapter{test}

\end{document}

And I do not understand the error raised:

Missing number, treated as zero.

<to be read again> 
                   \c@0 
l.50 \chapter{test}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

The result can be seen at: https://fr.sharelatex.com/project/576e90018ad9fc69396c79eb

Thanks for your help

1 Answer 1

6

This was caused by \value{0}, which is not valid. Simply 0 is enough. use \value only when accessing counters, as you do with \value{chapter}.

Also, you don't need to use \makeatletter/ \makeatotherhere. See What do \makeatletter and \makeatother do?, though I suspect you already know this.

Output

enter image description here enter image description here

Code

\documentclass{memoir}
\usepackage[utf8]{inputenc}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usepackage{arrayjob}

\title{demo}


\newarray\dnaletters
\readarray{dnaletters}{A&C&G&T}
\colorlet{Random1}{cyan}
\colorlet{Random2}{yellow}
\colorlet{Random3}{red}
\colorlet{Random4}{green}

%\makeatletter % not needed here. You are not accessing commands with @ in them.
    \makechapterstyle{thesisStyle}{
        \renewcommand{\chapternamenum}{}
        \renewcommand{\chapnumfont}{\normalfont\Huge\bfseries}
        \renewcommand{\printchapternum}{}
        \renewcommand{\printchaptername}{}
        \renewcommand\printchaptertitle[1]{
            \begin{tikzpicture}[remember picture,overlay,shift={(current page.north west)},yshift=-3cm]
                \path[fill=Black] (0,0) rectangle(\paperwidth,3cm);
                \foreach \x in {0,1, ..., 70}{
                    \foreach \y in {0, ...,7} 
                        \pgfmathsetmacro\Random{random(1,4)}
                    \node[draw=none,color=Random\Random,anchor=south west,font=\tiny,xshift=-.05cm] at (\x*.3cm,\y*.33cm) {\dnaletters(\Random)};
                };
                \node[anchor=east,xshift=.9\paperwidth,rectangle, rounded corners=20pt,inner sep=11pt, fill=MidnightBlue] {
                    \ifnum\value{chapter}>0% \value{0}, use \value only for accessing the value of a counter.
                        \normalfont\Huge\bfseries\color{white}\thechapter|~##1
                    \else
                        \normalfont\Huge\bfseries\color{white}##1
                    \fi
                };
            \end{tikzpicture}
        }
        \renewcommand{\afterchapternum}{}
    }
%\makeatother not needed either

\headstyles{thesisStyle}
\chapterstyle{thesisStyle}

\begin{document}

\tableofcontents
\chapter{test}
\end{document}
0

You must log in to answer this question.

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