TeX - LaTeX Asked on June 28, 2021
I’m writing a LaTeX template.cls
and am trying to redefine how the chapter, section and other headings are shown in the file. To do this, I’m using titleformat
from titlesec
to accomplish this. Here’s the code I’m currently using in my template file:
RequirePackage{titlesec}
titleformat{chapter}[block]
{normalfontbfseriesHuge}
{{chaptertitlename}~arabic{chapter}:}
{0pt}{}[]
titleformat{section}[block]
{normalfontbfserieshuge}
{Sarabic{chapter}.arabic{section}:~}
{0pt}{}[]
titleformat{subsection}[block]
{normalfontbfseriesLarge}
{arabic{chapter}.arabic{section}.arabic{subsection}:~}
{0pt}{}[]
This block works nicely as expeced. For example, the following block will produce the image’s output:
chapter{The tale of the chapter}
section{Starring: The section}
subsection{Directed by: The subsection}
My problem is that, while this is a good implementation, it interferes with the appendix
package (and surely others) in that the chapter is defined as an arabic number and can’t be changed into an alphabetic index. So, even though the appendices’ sections are shown in the table of contents as [A-Z].[1.9]
, they’re shown as [1-9].[1-9]
in the actual document.
To fix this, I’m trying to define the title format like this:
titleformat{chapter}[block]
{normalfontbfseriesHuge}
{{chaptertitlename}~thechapter:}
{0pt}{}[]
However, I’m getting compilation this error:
! Undefined control sequence.
<argument> {chaptertitlename } thechapter:
l.29 chapter{The tale of the chapter}
I’ve also found that the problem is not that thechapter
isn’t usable in the whole *.cls
file, but that it’s not usable in that particular block (maybe because it’s referencing its own heading?). For example. the following doesn’t produce any compilation errors and produces the same output as the image above:
titleformat{section}[block]
{normalfontbfserieshuge}
{Sthechapter.arabic{section}:~}
{0pt}{}[]
However, using thesection
in titleformat{section}
produces a compilation error:
titleformat{section}[block]
{normalfontbfserieshuge}
{Sthesection:~}
{0pt}{}[]
! Undefined control sequence.
<argument> S thesection:
l.30 section{Starring: The section}
I truly am at a loss here. What am I doing wrong? Should I be using a reference other than the*
? Have I found LaTeX’s ceiling? What can I do to make this work? Thank you very much!
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP