So what I have works, but I am looking for a cleaner / better approach.
I have a titlepage which needs a \maketitle in the form of a table (Tabular actually). However, when options are missing they should just be removed from the table. Similarly if no options are given, no table should be printed.
For instance
\def\@author{Jane doe}
\def\@date{\today}
\def\@verifier{Joe Doe}
Should produce
While
\def\@author{Jane doe}
\def\@date{}
\def\@verifier{}
becomes
This is my current idea, presented in as minimal of an example as I could make
\documentclass{article}
\usepackage{etoolbox}
\usepackage{booktabs}
\makeatletter
\def@author{}
\def@date{}
\def@verifier{}
% Comment out the lines bellow to test
\def@author{Jane doe}
\def@date{\today}
\def@verifier{Joe Doe}
\newcommand{\maketitletable}{
%
\newcommand{\authorname}{author}
\newcommand{\datename}{date}
\newcommand*{\verifiername}{verifier}
%
\ifstrempty{@author@date@verifier}{}{
\noindent
\begin{tabular}{p{0.2\textwidth} p{0.2\textwidth} p{\dimexpr 0.6\textwidth - 4\tabcolsep}}\toprule
\ifdefempty{@author}{}{& \authorname{} & @author \}
\ifdefempty{@date}{}{& \datename{} & @date \}
\ifdefempty{@verifier}{}{& \verifiername{} & @verifier \}
\bottomrule
\end{tabular}%
}
}
\makeatother
\begin{document}
\maketitletable
\end{document}
Just for reference, In my real code I do something like the following (I have many more)
\usepackage{xparse}
\ExplSyntaxOn
% Provide keys.
\keys_define:nn { babylonia }
{
author .tl_set:N = \@author,
author .initial:n = {},
date .tl_set:N = \@date,
date .initial:n = {},
verifier .tl_set:N = \@verifier,
}
% Provide key setting command.
\NewDocumentCommand\OUSsetup{ m }{
\keys_set:nn { babylonia } { #1 }
}
\ExplSyntaxOff
and then
\makeatletter
\renewcommand{\maketitle}{%
...
minimal working example goes in here
...
}
\makeatother
Before finally setting
\OUSsetup{
author = Jane Doe,
date = 01.12.2021,
verifier = Joe Doe,
}
\begin{document}
\maketitle
\end{document}
I am guessing this makes no difference to how the table is implemented.



.code:ninterface to simply specify the code to be executed. If the user specifies the keys in correct order (unlikely?) just use that to typeset the rows directly – user202729 Jun 18 '22 at 11:32\Xnamealways equalsXas these are defined by me. I just want to avoid some of the repetition =) And no, we can not rely on the users to input the keys in the correct order. Also a bit messy to avoid printing thebottomrule/toprulewhen no keys are present. Note that not every key in\OUSsetupwill be in the table. – N3buchadnezzar Jun 18 '22 at 11:43