TeX - LaTeX Asked by Roxy on April 30, 2021
I have a memoir document with custom TOC spacing:
documentclass[oneside]{memoir}
renewcommand{cftchapteraftersnum} {quad}
renewcommand{cftchapterdotsep} {cftsectiondotsep}
renewcommand{cftchapterfont} {cftsectionfont}
renewcommand{cftchapterleader} {cftsectionleader}
renewcommand{cftchapterpagefont} {cftsectionpagefont}
renewcommand{cftchapterpresnum} {hfill}
setlength {cftbeforechapterskip}{0.5em}
setlength {cftchapternumwidth} {10em}
begin{document}
frontmatter
chapter{Preface}
tableofcontents*
mainmatter
chapter{Alpha}
chapter{Beta}
end{document}
This generates a TOC like this:
I cannot find any memoir options to give non-numbered entries a space at the beginning so that I can line up the Preface entry with the numbered chapter names (i.e. Preface left-aligned with Alpha). Any way to do this?
Add the following lines after loading the memoir
class.
usepackage{xpatch}
makeatletter
xpatchcmd@chapter
{addcontentsline{toc}{chapter}{f@rtoc}}%
{addcontentsline{toc}{chapter}{protectchapternumberline{}f@rtoc}}%
{}%
{}
makeatother
This will handle only the preface. chapter*
headings in the main part are handled differently. For these, it is sufficient to add the line
renewcommandmemchapstarinfo[2]{addcontentsline{toc}{chapter}{protectchapternumberline{}#1}}
documentclass[oneside]{memoir}
usepackage{xpatch}
makeatletter
xpatchcmd@chapter
{addcontentsline{toc}{chapter}{f@rtoc}}%
{addcontentsline{toc}{chapter}{protectchapternumberline{}f@rtoc}}%
{}%
{}
makeatother
renewcommandmemchapstarinfo[2]{addcontentsline{toc}{chapter}{protectchapternumberline{}#1}}
renewcommand{cftchapteraftersnum} {quad}
renewcommand{cftchapterdotsep} {cftsectiondotsep}
renewcommand{cftchapterfont} {cftsectionfont}
renewcommand{cftchapterleader} {cftsectionleader}
renewcommand{cftchapterpagefont} {cftsectionpagefont}
renewcommand{cftchapterpresnum} {hfill}
setlength {cftbeforechapterskip}{0.5em}
setlength {cftchapternumwidth} {10em}
begin{document}
frontmatter
chapter{Preface}
tableofcontents*
mainmatter
chapter{Alpha}
section{Alpha 1}
section{Alpha 2}
chapter*{Beta}
section{Beta 1}
section{Beta 2}
end{document}
Correct answer by gernot on April 30, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP