TransWikia.com

Problem with centering the contents title

TeX - LaTeX Asked by jonnybolton16 on May 1, 2021

I sometimes get the fatal error

TeX capacity exceeded, sorry [input stack size=5000].

reserved@a ->def reserved@a 
            *{ttl@assign@i {@tempskipb }}reserved@a 
l.10 tableofcontents
                     
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

when I use renewcommand{contentsname}{centering Contents} to place the title of the table of contents in the center. I have no idea why, but for some documents it works, and for others it doesn’t. The preambles are almost identical. Does anyone know why it’s sometimes not working, and how I can fix it?

As an example, here is a document for which it doesn’t work:

documentclass[11pt,a4paper]{article}                       % 10pt default. Article = subsubsection numbered, no chapter, notitlepage

%%% Packages - always used 
usepackage[utf8]{inputenc}                                 % Overleaf's default file encoding
usepackage{amsmath, amssymb, amsthm}                       % AMS standards
usepackage[margin=1in]{geometry}                           % Set margins (use "=1.5cm" to make smaller)
usepackage[compact]{titlesec}                              % Reduce space below section titles (and allow title format editing)
allowdisplaybreaks                                         % Allow multiline equations to span pages
interfootnotelinepenalty=10000                             % Ensure footnotes don't span pages

%%% Packages - toggle usage
usepackage{hyperref}                                       % Hyperlinks
usepackage{cleveref}                                       % Clever references
newcommand{crefrangeconjunction}{--}                      % '-' for range of references
renewcommand{contentsname}{centering Contents}           % Contents title centred
usepackage{tikz}                                           % Tikz pictures
graphicspath{{images/}}                                    % Set image folder
usepackage{subfig}                                         % Use "subfloat[]{}" for sub-figures
usepackage[format=hang,font=small,labelfont=bf]{caption}   % Caption set-up
usepackage{rotating}                                       % "sidewaysfigure" and "sidewaystable" environments
usepackage{float}                                          % "H" float specifier
%usepackage{showlabels}                                     % Show labels

%%% Title
title{Measuring the Behaviour of Submerged Jets}
author{Jonathan Bolton}

%%% Headers & Footers
usepackage{fancyhdr}
pagestyle{fancy}
setlength{headheight}{13.6pt}
fancyhf{}
lhead{Lab Report}
chead{MATH5453: Foundations of Fluid Dynamics}
rhead{Jonathan Bolton}
lfoot{}
cfoot{thepage}
rfoot{}

%%% Bibliography
usepackage[style=numeric-comp,sorting=none,sortcites=false,maxbibnames=99,maxcitenames=2]{biblatex}
addbibresource{bib.bib}
DeclareFieldFormat[article]{title}{#1}                         % Remove " from article title
DeclareFieldFormat{url}{Available fromaddcolonspaceurl{#1}} % Add "available from:" to url
renewbibmacro{in:}{}                                           % Remove "in"
renewbibmacro{volume+number+eid}{%                             % Change volume/number syntax
    textbf{printfield{volume}}printfield[parens]{number}setunit{addcommaspace}printfield{eid}}

%%% SI setup
usepackage{siunitx}
sisetup{range-phrase=-}

begin{document}
maketitle
tableofcontents
noindenthrulefill
newpage
%========================
section{Test}
%========================

%========================
newpage
printbibliography[heading=bibintoc]
%========================
end{document}

and here is a document for which it does work

documentclass[11pt,a4paper]{article}                       % 10pt default. Article = subsubsection numbered, no chapter, notitlepage

%%% Packages - always used 
usepackage[utf8]{inputenc}                                 % Overleaf's default file encoding
usepackage{amsmath, amssymb, amsthm}                       % AMS standards
usepackage[margin=1in]{geometry}                           % Set margins (use "=1.5cm" to make smaller)
usepackage[compact]{titlesec}                              % Reduce space below section titles (and allow title format editing)
allowdisplaybreaks                                         % Allow multiline equations to span pages
interfootnotelinepenalty=10000                             % Ensure footnotes don't span pages

%%% Packages - toggle usage
usepackage{hyperref}                                       % Hyperlinks
usepackage{cleveref}                                       % Clever references
newcommand{crefrangeconjunction}{--}                      % '-' for range of references
renewcommand{contentsname}{centering Contents}           % Contents title centred
usepackage{tikz}                                           % Tikz pictures
usetikzlibrary{patterns}
graphicspath{{images/}}                                    % Set image folder
usepackage{subfig}                                         % Use "subfloat[]{}" for sub-figures
usepackage[format=hang,font=small,labelfont=bf]{caption}   % Caption set-up
usepackage{multicol}                                       % "multicols" environment 
%usepackage{showlabels}                                     % Show labels

%%% Title
title{The Immersed Boundary Method for Fluid-Structure Interaction Problems}
author{Me}

%%% Headers & Footers
usepackage{fancyhdr}
pagestyle{fancy}
setlength{headheight}{13.6pt}
fancyhf{}
lhead{Literature Review}
chead{COMP5454M: Fluid-Structure Interactions}
rhead{Me}
lfoot{}
cfoot{thepage}
rfoot{}

%%% 'Closed' sqrt symbol
usepackage{letltxmacro}
makeatletter
letoldr@@tr@@t
defr@@t#1#2{%
setbox0=hbox{$oldr@@t#1{#2,}$}dimen0=ht0
advancedimen0-0.2ht0
setbox2=hbox{vrule heightht0 depth -dimen0}%
{box0lower0.4ptbox2}}
LetLtxMacro{oldsqrt}{sqrt}
renewcommand*{sqrt}[2][ ]{oldsqrt[#1]{#2}}
makeatother

%%% Bibliography
usepackage[style=numeric-comp,sorting=none,sortcites=false,maxbibnames=99,maxcitenames=2]{biblatex}
addbibresource{bib.bib}
DeclareFieldFormat[article]{title}{#1}                         % Remove " from article title
DeclareFieldFormat{url}{Available fromaddcolonspaceurl{#1}} % Add "available from:" to url
renewbibmacro{in:}{}                                           % Remove "in"
renewbibmacro{volume+number+eid}{%                             % Change volume/number syntax
    textbf{printfield{volume}}printfield[parens]{number}setunit{addcommaspace}printfield{eid}}

%%% New commands
newcommand{dd}[2]{frac{partial #1}{partial #2}}
newcommand{mtext}[1]{enspacetext{#1}enspace}

begin{document}
maketitle
tableofcontents
noindenthrulefill
newpage
%========================
section{Test}
%========================

%========================
newpage
printbibliography[heading=bibintoc]
%========================
end{document}

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP