# Missing number, treated as zero when defining numbered chapter

I'm getting what appears to be a common error, but I can't figure out how to fix it. I have the following document, which I'm processing using xelatex.

\documentclass[12pt,english,oldfontcommands,openright]{memoir}

% For setting line height of individual blocks of text
\DisemulatePackage{setspace}
\usepackage{setspace}

% Select Font
%\usepackage{charter}
% Use GNU FreeSerif Font
\usepackage{fontspec}

% Great font for title page and chapter headings, but not the rest
Path           = fonts/,
BoldFont       = Quicksand-Bold.ttf,
ItalicFont     = Quicksand-Regular.ttf,
BoldItalicFont = Quicksand-Bold.ttf
]

\usepackage{titlesec}
\titleformat{\chapter}[display]

% Main text will be typeset in this font
\setmainfont{GaramondNo8-Reg.ttf}[
Path           = fonts/,
BoldFont       = GaramondNo8-Med.ttf,
ItalicFont     = GaramondNo8-Ita.ttf,
BoldItalicFont = GaramondNo8-MedIta.ttf
]

\renewcommand{\familydefault}{\rmdefault}

%showframe option VERY USEFUL for debugging!
% lmargin = inner, rmargin = outer

% In addition to paperwidth and paperheight in the geometry package setting,
% I need to set the stock size, a command defined by the memoir class, to actually
% change the physical page size to something custom.
\setstocksize{10in}{7in}

\setcounter{chapter}{0}
\setcounter{tocdepth}{0}
\usepackage{textcomp}
\usepackage{graphicx}
\usepackage{sidecap}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{microtype} % reduce amount of unnecessary and broken hyphenation
\usepackage{lettrine}
\renewcommand{\LettrineTextFont}{\rmfamily} % text following drop cap lowercase
\let\footruleskip\undefined % make memoir ignore fancyhead method
\usepackage{fancyhdr}

\fancypagestyle{fancyfacing}{
\fancyfoot{} % clear foot
}

% Redefine the plain page style for chapters
\fancypagestyle{plain}{
\fancyfoot{} % clear foot
\fancyfoot[CO]{\thepage}
\fancyfoot[CE]{\thepage}
}

% \renewcommand*{\printchapternonum}{\centering} % alternative centre chapter
\renewcommand\chaptitlefont{\centering\normalfont\huge\bfseries\noindent} %center chapter titles
\setlength{\pfbreakskip}{\baselineskip} % make pfbreak one line space height
\setlength{\parskip}{0pt} %gap between paras same as line space
\setlength{\parsep}{0pt} %gap between paras same as line space

\makeatother

\usepackage{babel}

\begin{document}
\frontmatter
\pagestyle{empty}
\vspace*{\stretch{1}}

% Have an extra blank page at the beginning of the book.
\newpage{}
\vspace*{\stretch{1}}
\newpage{}

% Title page
\include{include/titlepage}

\newpage{}

\newpage{}

% Insert extra blank page
\newpage{}
\vspace*{\stretch{1}}
\newpage{}

\clearpage{}
\mainmatter
\pagestyle{fancyfacing}

\chapter{Chapter name}

Some text for the chapter

\pagestyle{empty}

% Skip a page so that we start on the right again
\newpage{}
\vspace*{\stretch{1}}
\newpage{}

% Insert extra blank page (both sides)
\newpage{}
\vspace*{\stretch{1}}
\newpage{}

\end{document}


I'm getting the following error:

! Missing number, treated as zero.
\relax
l.1 \chapter{Chapter Name}


If I use \chapter*{Chapter Name} instead of \chapter{Chapter Name}, I don't get that error, but unfortunately I need to generate a table of contents, so I need my chapters to be numbered.

Any help figuring out where this error is coming from would be greatly appreciated! :)

• I've tried adding the calc package, but that doesn't work. Oct 14, 2017 at 10:52
• A minimal working example (MWE) helps a lot! Just try eliminating from the code until the error doesn't appear any more -- that should point you in the right direction (seems like titlesec is the culprit here). Also, eliminate everything not relevant to the problem, so the document compiles. Fonts, definitions for fancy headers etc. are not relevant here -- and I got lots of errors before getting to your error message because your document requires fonts I don't have installed. Anyway, I'll try to come up with a solution, might take some time, though. :-) Oct 14, 2017 at 11:07
• From the documentation of titlesec: "Unfortunately, it is not compatible with memoir, which provides its own tools with a limited subset of the features available intitlesec." Oct 14, 2017 at 11:29
• BTW, not all macros have arguments. Adding {} just prevents the macro from absorbing any blanks to the right. Oct 14, 2017 at 13:59
• Andreas, you're right. I'll minimize my code and remove references to local files in the future. Oct 14, 2017 at 14:24

The problem is the missing <sep> argument to \titleformat. You can't leave that one empty. That's the number missing. The following compiles (but still titlesec's documentation suggests you shouldn't use it with memoir):

\documentclass[12pt,oldfontcommands,openright]{memoir}

\usepackage{titlesec}
\titleformat{\chapter}[display]

\renewcommand{\familydefault}{\rmdefault}

\setstocksize{10in}{7in}

\setcounter{tocdepth}{0}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
%\renewcommand\chaptitlefont{\centering\normalfont\huge\bfseries\noindent} % this line appears to have no effect with titlesec

\begin{document}
\chapter{Chapter name}

Some text for the chapter
\end{document}

• That did it. Thank you! I'll be wary of titlesec and memoir issues. So far, it's been working for me (until I had this problem.) Oct 14, 2017 at 14:26