Knit Error: "! Package mathspec Error: 'amsmath' must be loaded earlier than 'mathspec'."
navenachaitoo opened this issue · comments
Thanks so much for sharing these files as a template. When I knit the RMD file, I get the below error:
! Package mathspec Error: 'amsmath' must be loaded earlier than 'mathspec'.
Inserting \RequirePackage{amsmath}
before \RequirePackage{mathspec}
in the .cls file included in the repository still generates the same error. And, while removing \RequirePackage{mathspec}
will allow the PDF to compile, we lose the chapter numbering which affects the table and figure numbering as well (see attached PDF render).
Any suggestions for getting around this error or getting the chapter/section numbering going again would be greatly appreciated.
PDF render of sample dissertation missing chapter numbers
If helpful, my session info is:
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.0.1
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.2 fastmap_1.1.0 htmltools_0.5.2 tools_4.1.2 yaml_2.2.1 rmarkdown_2.11
[7] knitr_1.36 xfun_0.28 digest_0.6.28 rlang_0.4.12 evaluate_0.14
As a minimum working example, the repository can be downloaded or forked and the R markdown file can be knitted to see if the error is replicated.
@kaseyzapatka, yes, this is what ended up working for me:
- Commenting out the mathspec package in the DissertateCUNY.cls file.
- And, in order to get the chapter and section numbering going again, adding the "number_sections: true" option to the YAML header in my manuscript.Rmd file.
Here is pseudo code for how to set-up the manuscript.Rmd YAML header:
---
title: 'Title'
author: 'Author'
csl: APA_format.csl
output:
pdf_document:
includes:
in_header: preamble.tex
number_sections: true
keep_tex: yes
latex_engine: xelatex
word_document: default
geometry:
- top=1in
- bottom=1in
- right=1in
- left=1in
mainfont: Times New Roman
nocite: |
@Burnham2002
@Iacobucci2007
@Mood2010
@Norton2012
@Edwards2007
@Hastie2009
documentclass: DissertateCUNY
params:
abstract: Write abstract here.
advisor: Advisor Name
chair: Chair Name
committee1: Committee Member 1
committee2: Committee Member 2
committee3: Committee Member 1
degree: Doctor of Philosophy
executiveOfficer: Executive Officer Name
field: Field
year: '2022'
bibliography: references.bib
---
And, here is pseudo code for the DissertateCUNY.cls file (all @nbrosowsky's work w/ just the mathspec package commented out)
% -------------------------------------------------------------------
% @LaTeX-class-file{
% filename = "DissertateCUNY.cls",
% version = "1.0",
% date = "14 12 2018",
% codetable = "ISO/ASCII",
% keywords = "LaTeX, Dissertate",
% note = "Based on 'Dissertate' by Jordan Suchow and 'DissertateUSU' by Tyson Barrett,
% For support, email 'nbrosowsky@gradcenter.cuny.edu',
% docstring = "Class for a dissertation at City University of New York."
% --------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{DissertateCUNY}[2018/12/14 v1.0 DissertateCUNY Class]
\LoadClass[12pt, oneside, letterpaper]{book}
%%%%%%%%%%%%%%%%%
%% Options %%
%%%%%%%%%%%%%%%%%
\RequirePackage{etoolbox}
%{{{ Line-spacing control
\RequirePackage{setspace}
\newcommand{\singlespaced}{\singlespacing}
\newcommand{\doublespaced}{\doublespacing}
\newcommand{\triplespaced}{\setstretch {2.6}}
%}}}
% Text layout.
\usepackage{ragged2e}
\RaggedRight
\tolerance=9999
\emergencystretch=10pt
\hyphenpenalty=10000
\exhyphenpenalty=100
\RequirePackage{graphicx}
\usepackage{fixltx2e}
\usepackage{parskip}
\setlength{\parindent}{1cm}
\RequirePackage{lettrine}
\RequirePackage{setspace}
\RequirePackage{verbatim}
\usepackage{indentfirst}
% Fonts.
\RequirePackage{color}
\RequirePackage{xcolor}
\usepackage{hyperref}
\RequirePackage{url}
\RequirePackage{amssymb}
%\RequirePackage{mathspec}
\AtBeginEnvironment{tabular}{\addfontfeature{RawFeature=+tnum}}
\widowpenalty=300
\clubpenalty=300
\RequirePackage[labelfont={bf,small,singlespacing},
textfont={small,singlespacing},
singlelinecheck=false,
margin=0pt,
figurewithin=chapter,
tablewithin=chapter]{caption}
\RequirePackage{microtype}
\usepackage{placeins} %% floatbarrier command
\usepackage{chngcntr}
\counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Headings & Headers %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage[tiny, md, sc]{titlesec}
\setlength{\headheight}{15pt}
\RequirePackage{titling}
\RequirePackage{lastpage}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Appendix %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\nocontentsline}[3]{}
\newcommand{\tocless}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}\egroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Page number in upper right corner %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{fancyhdr}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\thepage} % page number in upper right corner
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: TABLE of CONTENTS -auto fill %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setcounter{tocdepth}{2}
\usepackage[titles]{tocloft}
\usepackage[titletoc]{appendix}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}}
\renewcommand{\cftchapfont}{\normalsize \normalfont}
\newcommand{\hsp}{\hspace{10pt}}
\renewcommand*{\tableofcontents}{
\singlespaced
\chapter*{ \begin{center} \textnormal{CONTENTS} \end{center}}
\hfill Page\\
\@starttoc{toc}
\newpage
\doublespaced
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: List of FIGURES -auto fill %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%{{{ List of Figures
% LoF should be single-spaced within entries and double-spaced between entries
\renewcommand*{\listoffigures}{
\singlespaced
\chapter*{\begin{center} \textnormal{LIST OF FIGURES} \end{center}}
\addcontentsline{toc}{chapter}{LIST OF FIGURES}
\noindent Figure \hfill Page\\
\@starttoc{lof}
\newpage
\doublespaced
}
% Ensure double-spacing between entries
\renewcommand*\l@figure{\par\addvspace{\bigskipamount}\pagebreak[2]
\@dottedtocline{1}{1.5em}{2.3em}}
%}}}
% Tables
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{array}
\newcolumntype{x}[1]{%
>{\centering\arraybackslash}m{#1}}%
% Allow for long captions and float captions on opposite page of figures
% \usepackage[rightFloats, CaptionBefore]{fltpage}
% Don't let floats cross subsections
% \usepackage[section,subsection]{extraplaceins}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: List of TABLES - auto fill %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%{{{ List of Tables
% LoT should be single-spaced within entries and double-spaced between entries
\renewcommand*{\listoftables}{
\singlespaced
\chapter*{ \begin{center} \textnormal{LIST OF TABLES} \end{center}}
\addcontentsline{toc}{chapter}{LIST OF TABLES}
\noindent Table \hfill Page\\
\@starttoc{lot}
\newpage
\doublespaced
}
% Ensure double-spacing between entries
\renewcommand*\l@table{\par\addvspace{\bigskipamount}\pagebreak[2]
\@dottedtocline{1}{1.5em}{2.3em}}
%}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: SECTION HEADINGS- auto fill %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\setthesection}{\roman{chapter}.\roman{section}}
\usepackage{quotchap}
\parskip 0pt
\usepackage{titlesec, blindtext, color}
\titleformat{\chapter}[display]
{\vspace{-60pt}\center} %% spacing of chapter headings
{{CHAPTER \thechapter}}
{10pt}
{}
\titleformat{\section}[display]
{\normalfont\normalsize\bfseries\center}
{}
{0pt}
{{}}
\titleformat{\subsection}[display]
{\normalfont\normalsize\bfseries}
{}
{0pt}
{{}}
\titleformat{\subsubsection}[runin]
{\normalfont\normalsize\bfseries\itshape}
{}
{0pt}
{{}}
\titlespacing*{\subsubsection}{\parindent}{1ex}{0.5em}
% An environment for paragraph-style section.
\providecommand\newthought[1]{%
\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}%
\textsc{#1}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Floats: Figures & Tables %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
\captionsetup{justification=raggedright}
\setlength{\textfloatsep}{30pt plus 1.0pt minus 2.0pt}
\setlength{\intextsep}{30pt plus 1.0pt minus 2.0pt}
\setlength{\floatsep }{30pt plus 1.0pt minus 2.0pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: Title Page - info filled above %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\renewcommand{\maketitle}{
\begin{titlepage}
\begin{center}
~\vspace{2in}
\doublespaced
\textsc{\MakeUppercase{\@title}} \\[0.5in]
by \\[0.5in]
\textsc{\MakeUppercase{\@author}}
\vspace{\fill}
\doublespaced
A dissertation submitted to the Graduate Faculty in \field in partial fulfillment of the requirements for the degree of \degree, The City University of New York.\\[0.25in]
\yeardegree
\end{center}
\end{titlepage}
\pagenumbering{roman}
\setcounter{page}{2}
\clearpage
}
\newcommand{\approvalpage}{
\newpage
\begin{center}
\singlespaced
\@title\\
\doublespaced
by\\
\@author \\
\vspace{50pt}
\singlespaced
This manuscript has been read and accepted for the Graduate Faculty in \field in satisfaction of the dissertation requirement for the degree of \degree.\\
\end{center}
\vspace{50pt}
\noindent\begin{tabular}{ll}
\makebox[2.8in]{\hrulefill} & \makebox[2.8in]{\hrulefill}\\
Date & \chairperson \\
& Chair of Examining Committee \\
& \\
& \\
& \\
& \\
\makebox[2.8in]{\hrulefill} & \makebox[2.8in]{\hrulefill}\\
Date & \EO \\
& Executive Officer \\
\end{tabular}
\vspace{50pt}
\begin{center}
\doublespaced
Supervisory Committee \\
\committeeone \\
\committeetwo \\
\committeethree \\
\end{center}
\vspace{\fill}
\begin{center}
\textsc{THE CITY UNIVERSITY OF NEW YORK}
\end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: Copy Right - info filled above %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\copyrightpage}{
\phantom{}\vspace{\fill}
\begin{center}
\doublespaced
\copyright~\yeardegree\\
\textsc{\MakeUppercase{\@author}}\\
All Rights Reserved\\
\end{center}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LAYOUT: Abstract - info filled above %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\abstractpage}{
\newpage
\pagestyle{fancy}
\fancyhead[L]{Abstract}
\fancyhead[R]{\thepage}
\fancyfoot[C]{}
\chapter*{ABSTRACT}
\addcontentsline{toc}{section}{Abstract}
\doublespacing
\begin{center}
\@title \\
\vspace{12pt}
by \\
\vspace{12pt}
\@author \\
\end{center}
\vspace{12pt}
\singlespacing
\noindent Advisor: \advisor \\
\vspace{12pt}
\doublespacing
\abstract \\
}