Created
February 24, 2023 13:59
-
-
Save jfdm/e1d368d721018324267a9a34c572b961 to your computer and use it in GitHub Desktop.
Variables in LaTeX using komascript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{xspace} | |
% The Magic Sauce. | |
\usepackage{scrletter} | |
\makeatletter | |
\newkomavar[urghhh]{documentTitle} | |
\setkomavar{documentTitle}{\@title} | |
\newkomavar[urgh]{documentSubTitle} | |
\setkomavar{documentSubTitle}{} | |
\newcommand{\subtitle}[1]{\setkomavar{documentSubTitle}{#1}} | |
\newcommand{\theTitle}{\usekomavar{documentTitle}} | |
\newcommand{\theSubtitle}{\usekomavar{documentSubTitle}} | |
\newcommand{\theFullTitle}{% | |
\theTitle% | |
\ifkomavarempty{documentSubTitle} | |
{} | |
{:\xspace\theSubtitle}} | |
\makeatother | |
\title{Foo} | |
\subtitle{Bar} | |
\begin{document} | |
\begin{enumerate} | |
\item\theTitle{} | |
\item \theSubtitle{} | |
\item \theFullTitle{} | |
\end{enumerate} | |
\subtitle{} | |
\begin{enumerate} | |
\item \theTitle{} | |
\item \theSubtitle{} | |
\item \theFullTitle{} | |
\end{enumerate} | |
\end{document} | |
%%% Local Variables: | |
%%% mode: latex | |
%%% TeX-master: t | |
%%% End: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment