2

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
\newfontfamily\headingfont{Quicksand-Regular.ttf}[
    Path           = fonts/,
    BoldFont       = Quicksand-Bold.ttf,
    ItalicFont     = Quicksand-Regular.ttf,
    BoldItalicFont = Quicksand-Bold.ttf
]

\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\headingfont\centering}{\thechapter}{}{\Huge\textbf}

% 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!
\usepackage[xetex,paperwidth=7in,paperheight=10in,includehead,includefoot]{geometry}
% lmargin = inner, rmargin = outer
\geometry{verbose,tmargin=0.5in,bmargin=0.5in,lmargin=0.5in,rmargin=0.5in,headheight=18pt,headsep=0.25in,footskip=0.5in}

% 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}{
\fancyhead{} %clear head
\fancyfoot{} % clear foot
\fancyfoot[CO]{\headingfont\thepage}
\fancyfoot[CE]{\headingfont\thepage}
\fancyhead[CE]{\itshape Title}
\fancyhead[CO]{\itshape Athor}
\renewcommand{\headrulewidth}{0pt} %hide header rule
}

% Redefine the plain page style for chapters
\fancypagestyle{plain}{
\fancyhead{} %clear head
\fancyfoot{} % clear foot
\fancyfoot[CO]{\thepage}
\fancyfoot[CE]{\thepage}
\renewcommand{\headrulewidth}{0pt} %hide header rule
}

% \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{}

% Copyright page
\include{include/copyright}

\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.
<to be read again> 
                   \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! :)

5
  • 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. :-)
    – Andreas
    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."
    – Skillmon
    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

1 Answer 1

1

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}

\def\headingfont{\rmfamily}

\usepackage{titlesec}
\titleformat{\chapter}[display]
  {\headingfont\centering}{\thechapter}{0pt}{\Huge\textbf}

\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}
1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.