TeX - LaTeX Asked on May 6, 2021
I would like to customize the maketitle
by adding two new fields: department
and school
.
I want to add them in a custom-defined def@maketitle{%
. I naively tried this:
providecommand{school}[1]{newcommand{@school}[1]{school}}
LaTeX defines author
as
DeclareRobustCommand*author[1]{gdef@author{#1}}
You can define school
and department
in the same way:
DeclareRobustCommand*School[1]{gdef@School{#1}}
DeclareRobustCommand*Department[1]{gdef@Department{#1}}
@
may not occur in the name of a macro on user level, so you have either to enclose the definitions between makeatletter
and makeatother
(and put the commands into your preamble) or to put them into a file mydefs.sty
and load this file in the preamble with usepackage{mydefs}
.
Probably the easiest way to create a new maketitle
command is to leave the old one as it is and use it in your definition.
DeclareRobustCommand*Author[1]{gdef@Author{#1}}
newcommandMaketitle{%
author{@Author@School, @Department}%
maketitle
}
Note that we need a new author
command, as we need the original command to combine school and department with the author.
documentclass{article}
makeatletter
DeclareRobustCommand*School[1]{gdef@School{#1}}
DeclareRobustCommand*Department[1]{gdef@Department{#1}}
DeclareRobustCommand*Author[1]{gdef@Author{#1}}
newcommandMaketitle{%
author{@Author@School, @Department}%
maketitle
}
makeatother
begin{document}
title{My Article}
Author{It's me}
School{my school}
Department{my department}
Maketitle
end{document}
Correct answer by gernot 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