TeX - LaTeX Asked on January 14, 2021
I’d like to use title case in KOMA-script-typeset title page and section titles.
Of course, I can do
documentclass[version=last]{scrreprt} % it's 3.32
usepackage{titlecaps}
title{titlecap{The Beginning of the document}}
begin{document}
maketitle
tableofcontents
section{titlecap{My title with caps}}
end{document}
However, I’d like to have something idiomatic, say,
setkomafont{disposition}{rmfamilyMakeTitleCase}
How can I automate title-casing?
You could patch chapterlinesformat
, chapterlineswithprefixformat
, sectionlinesformat
, sectioncatchphraseformat
and maybe minisec
:
usepackage{titlecaps}
usepackage{xpatch}
newcommand*MakeTitleCase[1]{titlecap{#1}}
xpatchcmdchapterlinesformat{#3}{MakeTitleCase{#3}}{}{clfpatchfailed}
xpatchcmdchapterlineswithprefixformat{#3}{MakeTitleCase{#3}}{}{clwpfpatchfailed}
xpatchcmdsectionlinesformat{#4}{MakeTitleCase{#4}}{}{slfpatchfailed}
xpatchcmdsectioncatchphraseformat{#4}{MakeTitleCase{#4}}{}{scpfpatchfailed}
xpatchcmdminisec{#1}{MakeTitleCase{#1}}{}{mspatchfailed}
For the title you can use
newcommand*originaltitle{}
letoriginaltitletitle
renewcommandtitle[1]{originaltitle{MakeTitleCase{#1}}}
With
newcommand*originaladdchaptertocentry{}
letoriginaladdchaptertocentryaddchaptertocentry
renewcommand*addchaptertocentry[2]{originaladdchaptertocentry{#1}{MakeTitleCase{#2}}}
only chapter entries will use MakeTitleCase
in TOC.
If all entries in TOC should use MakeTitleCase
:
newcommand*originaladdtocentrydefault{}
letoriginaladdtocentrydefaultaddtocentrydefault
renewcommand*addtocentrydefault[3]{originaladdtocentrydefault{#1}{#2}{MakeTitleCase{#3}}}
Example:
documentclass[version=last]{scrreprt} % it's 3.32
usepackage{titlecaps}
usepackage{xpatch}
newcommand*MakeTitleCase[1]{titlecap{#1}}
xpatchcmdchapterlinesformat{#3}{MakeTitleCase{#3}}{}{clfpatchfailed}
xpatchcmdchapterlineswithprefixformat{#3}{MakeTitleCase{#3}}{}{clwpfpatchfailed}
xpatchcmdsectionlinesformat{#4}{MakeTitleCase{#4}}{}{slfpatchfailed}
xpatchcmdsectioncatchphraseformat{#4}{MakeTitleCase{#4}}{}{scpfpatchfailed}
xpatchcmdminisec{#1}{MakeTitleCase{#1}}{}{mspatchfailed}
newcommand*originaltitle{}
letoriginaltitletitle
renewcommandtitle[1]{originaltitle{MakeTitleCase{#1}}}
newcommand*originaladdtocentrydefault{}
letoriginaladdtocentrydefaultaddtocentrydefault
renewcommand*addtocentrydefault[3]{originaladdtocentrydefault{#1}{#2}{MakeTitleCase{#3}}}
title{The Beginning of the document}
author{Author}
begin{document}
maketitle
tableofcontents
chapter{A chapter with caps}
section{A section with caps}
minisec{A minisec with caps}
paragraph{A paragraph with caps}
Example text ...
end{document}
Correct answer by esdd on January 14, 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