Error applying Chapter Style in Memoir Class

I use memoir class, I get an error message file ended when scanning \makechapterstye

This is what I want. I get the code from "Variation over VZ39, contributed by Danie Els, Various chapter styles for the memoir class" by LarsMadsen

Can anyone help me please? This is the code :

\documentclass{memoir}
\usepackage{fourier} % or what ever
\usepackage[scaled=.92]{helvet}%. Sans serif Helvetica
\usepackage{color,calc}
\newsavebox{\ChpNumBox}
\definecolor{ChapBlue}{rgb}{0.00,0.65,0.65}
\makeatletter
\newcommand*{\thickhrulefill}{%
\leavevmode\leaders\hrule height 1\p@ \hfill \kern \z@}
\newcommand*\BuildChpNum[2]{%
\begin{tabular}[t]{@{}c@{}}
\makebox[0pt][c]{#1\strut} \\[.5ex]
\colorbox{ChapBlue}{%
\rule[10em]{0pt}{0pt}%
\rule{1ex}{0pt}\color{black}#2\strut
\rule{1ex}{0pt}}%
\end{tabular}}
\makechapterstyle{BlueBox}{%
\renewcommand{\chapnamefont}{\large\scshape}
\renewcommand{\chapnumfont}{\Huge\bfseries}
\renewcommand{\chaptitlefont}{\raggedright\Huge\bfseries}
\setlength{\beforechapskip}{20pt}
\setlength{\midchapskip}{26pt}
\setlength{\afterchapskip}{40pt}
\renewcommand{\printchaptername}{}
\renewcommand{\chapternamenum}{}
\renewcommand{\printchapternum}{%
\sbox{\ChpNumBox}{%
\BuildChpNum{\chapnamefont\@chapapp}%
{\chapnumfont\thechapter}}}
\renewcommand{\printchapternonum}{%
\sbox{\ChpNumBox}{%
\BuildChpNum{\chapnamefont\vphantom{\@chapapp}}%
{\chapnumfont\hphantom{\thechapter}}}}
\renewcommand{\afterchapternum}{}
\renewcommand{\printchaptertitle}[1]{%
\usebox{\ChpNumBox}\hfill
\parbox[t]{\hsize\width\ChpNumBox{1em}{%
\vspace{\midchapskip}%
\thickhrulefill\par
\chaptitlefont ##1\par}}%
}
\chapterstyle{BlueBox}
\begin{document}
\chapter{Introduction}
\end{document}


Error message : File ended while scanning use of \makechapterstyle.

-
You should add an example of your LaTeX code. – egreg Sep 4 '11 at 9:33
I have added the code egreg, Thanks you. – Verly Sep 4 '11 at 9:55

1 Answer

You're missing the closing brace in the last \parbox first argument, but as it is it means nothing:

\hsize\width\ChpNumBox{1em}


isn't a dimension. What you probably want is

\parbox[t]{\hsize-\wd\ChpNumbox-6pt}{...}


You need also to change the code in \BuildChpNum:

\newcommand*\BuildChpNum[2]{%
\begin{tabular}[t]{@{}c@{}}
\makebox[0pt][c]{#1\strut} \\[.5ex]
\colorbox{ChapBlue}{%
\rule[10em]{0pt}{0pt}%
\hspace{6pt}\color{black}#2\strut\hspace{6pt}%
}%
\end{tabular}}


Using a \rule to get a horizontal space is quite strange; moreover the two 1ex are different, as the first is from \normalfont and the second is from \bfseries. Adjust the 6pt to something that pleases you.

-
Thanks egreg, you're right . with this all running well : \parbox[t]{\hsize-\wd\ChpNumBox-1em}{% – Verly Sep 4 '11 at 12:08