TeX - LaTeX Asked on May 6, 2021
I’m writing a document template as a .tex file, that can simply be included at the beginning of any new document and loads all packages, defines headers, footers etc. called my_template.tex
.
Inside my_template.tex
, I use KOMA-Script to style the header like:
documentclass[
11pt,
a4paper,
]{scrarticle}
usepackage[page]{totalcount}
usepackage{scrlayer-scrpage}
setkomafont{pagehead}{normalfont}
ohead{Template Name Document Name small Page thepage~of totalpages}
cfoot{}
setlength{headheight}{14pt}
I want the user to be able to set the title somewhere inside the document, but use this definition inside the template. Something like:
input{my_template.tex}
...
begin{document}
...
title{My Document Title}
...
end{document}
How can I set the Document Name
inside the header to be My Document Title
? I would also like the same title for a maketitle
command.
One possibility:
documentclass[
11pt,
a4paper,
head lines=3
]{scrartcl}
usepackage[page]{totalcount}
usepackage{scrlayer-scrpage}
setkomafont{pagehead}{normalfont}
clearmainofpairofpagestyles
ohead{%
Template Name%
Ifstr{documentname}{}{}{documentname}%
small Page thepage~of totalpages
}
newcommand*documentname{}
letoriginaltitletitle
renewcommand*title[1]{defdocumentname{#1}originaltitle{#1}}
usepackage{blindtext}% only for dummy text
begin{document}
title{My title}
author{Author}
maketitle
blinddocument
end{document}
Correct answer by esdd on May 6, 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