%20Array-(Variablen-)Map-Syntax%2C%20um%20Dinge%20zu%20behalten.png)
Es tut mir leid, wenn dies bereits woanders besprochen wurde, aber wenn ja, konnte ich es nicht finden.
Ich bin der Autor einer Vorlage für eine akademische Abschlussarbeit für meine Universität, aber ich bin definitiv kein TeX-Experte. In dieser Vorlage verwende ich ausgiebig Konfigurationsdateien, die eine Ad-hoc-Array-Map (selbstdefiniert) verwenden. Beispiel:
\arraymay{cover}
\cover{phd}={phd_cover_file.pdf}
\cover{msg}={msc_cover_file.pdf}
\arraymap{margin}
\margin{cover,left}={5cm}
\margin{cover,right}={5cm}
\margin{cover,top}={4cm}
\margin{cover,bottom}={4cm}
\margin{main,left}={3cm}
\margin{main,right}={3cm}
\margin{main,top}={2cm}
\margin{main,bottom}={2cm}
Kommas in Schlüsseln werden aus optischen Gründen verwendet und als normale Zeichen betrachtet, d. h. in „ \margin{cover,bottom}={2cm}
“ ist der Schlüssel „ cover,bottom
“.
Ich kann später auf die Werte wie folgt zugreifen:
\def\manuscripttype{phd}
The cover file is ``\thecover[\manuscripttype]'' and the margins for the cover are ``\themargin[cover,left], \themargin[cover,right], \themargin[cover,top], and \themargin[cover,bottom].''
wird herstellen
The cover file is “phd_cover_file.pdf” and the margins for the cover are “3cm, 3cm, 2cm, and 2cm.”
Gibt es ein anderes (solides) Paket, das diese Funktionalität implementiert? Wenn nicht, gibt es eine solide Möglichkeit, sie zu implementieren (vielleicht basierend auf einem der KV-Pakete)? Danke.
Antwort1
Sie können dies tun mit pgfkeys
:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{pgfkeys}
\pgfkeys{
lourenco/.cd,
cover/phd/.initial={},
cover/msc/.initial={},
margin/cover/left/.initial=0pt,
margin/cover/right/.initial=0pt,
margin/cover/top/.initial=0pt,
margin/cover/bottom/.initial=0pt,
margin/main/left/.initial=0pt,
margin/main/right/.initial=0pt,
margin/main/top/.initial=0pt,
margin/main/bottom/.initial=0pt,
}
\newcommand{\setlourenco}[1]{\pgfkeys{lourenco/.cd,#1}}
\newcommand{\thecover}[1]{%
\pgfkeysvalueof{/lourenco/cover/#1}%
}
\newcommand{\themargin}[1]{%
\pgfkeysvalueof{/lourenco/margin/#1}%
}
%% settings
\setlourenco{
cover/phd=phd-cover-file.pdf,
cover/msc=msc-cover-file.pdf,
margin/cover/left=5cm,
margin/cover/right=5cm,
margin/cover/top=4cm,
margin/cover/bottom=4cm,
margin/main/left=3cm,
margin/main/right=3cm,
margin/main/top=2cm,
margin/main/bottom=2cm,
}
\def\manuscripttype{phd}
\begin{document}
The cover file is ``\thecover{\manuscripttype}'' and the margins
for the cover are ``\themargin{cover/left}, \themargin{cover/right},
\themargin{cover/top}, and \themargin{cover/bottom}.''
\end{document}