# writing newcommands, user interface advice request

I'd like to develop some good habits in LaTeX coding. I understand I'm in the novice category and I'm interested to hear advice.

We have a legacy document header that was created by some MS Word users and I have finger-painted LaTeX to match that, roughly. The header produced by the example code I discuss below is:

Where the image has NEEDarg10, NEEDarg11, NEEDarg12, those are placeholders where I wish I could put in author 2's information.

I first wrote that with the document and author info "in" a 3 column table, now I want to understand how to abstract that structure so that the in-document usage is cleaner. I want to hide the structure in the preamble or a style file.

I need to fit a lot of pieces of information into this header. I ran into the problem that newcommand allows only 9 arguments. That terminates my effort after author1 information.

%1 logo left
%2 logo right
%3 Title
%4 Guide number
%5 URL
%6 keywords
%7 Author1 name
%8 Author1 Affiliation
%9 Author1 email
% Wish I could have flexible method to insert more authors
%10 Author2 name
%11 Authot2 Affiliation
%12 Author2 email


Even if it would allow more than 9 arguments, the user interface is ugly. I'm imagining, somewhat unrealistically, that we'll get those in the correct order in the document:

\crmdahdr{logoleft.png}%1
{logoright.png}%2
{A Very Long Title: With a Possibly Long Subtitle}%3
{45}%4
{https://crmda.ku.edu/guides}%5
{\LaTeX, Programming}%6
{Firstname1 Lastname1}%7
{CRMDA}%8
{email1.edu}


General question: What is the best way to re-design this? I've been Googling a lot, don't know who to trust, which template style is good. It appears to me the most common approach is to have the user declare a lot of global variables, values which don't need to be explicitly passed into the function. Is that good?

Can you show me how to create a structure for author name, affiliation, and email, and pass those structs in as arguments, which can be used inside the newcommand?

I do not want to build this into an entirely new document class, I'd like to have freedom to put it as a tex or sty file into various kinds of documents. This one uses KOMA, I can't remember why.

\documentclass[11pt,letterpaper,english]{scrartcl}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setlength{\parskip}{\medskipamount}
\setlength{\parindent}{0pt}
\usepackage{color}
\usepackage{babel}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,
{hyperref}

\makeatletter

\@ifundefined{date}{}{\date{}}

\geometry{
lmargin=1in,
rmargin=1in,
tmargin=0.75in,
bmargin=1.0in,
marginparwidth=0pt,
footskip=1.5\baselineskip,
}

\usepackage{multicol}
\usepackage{listings}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[yyyymmdd,hhmmss]{datetime}

\usepackage{babel}
\usepackage{array}
\providecommand{\tabularnewline}{\\}

%1 logo left
%2 logo right
%3 Title
%4 Guide number
%5 URL
%6 keywords
%7 Author1 name
%8 Author1 Affiliation
%9 Author1 email
%Wish I could have
%10 Author2 name
%11 Authot2 Affiliation
%12 Author2 email

\newcommand{\crmdahdr}[9]{
\begin{tabular}{|>{\centering}p{1.25in}>{\raggedright}p{3.5in}>{\raggedleft}p{1.75in}|}
\hline
\begin{minipage}[c]{1.25in}%
\begin{center}
\textsc{\includegraphics[width=1.25in]{#1}}
\par\end{center}%
\end{minipage} & %
\begin{minipage}[c][1\totalheight][b]{3.5in}%
\bigskip
\begin{center}
\begin{minipage}[t][1\totalheight][b]{1\columnwidth}%
\begin{center}
\textbf{\large{}#3}\\
\rule[0.5ex]{1\linewidth}{1pt}
\par\end{center}%
\end{minipage}
\par\end{center}{\Huge \par}
\begin{minipage}[t]{1\columnwidth}%
\begin{center}
\textbf{#7}, #8 <#9>\\
\textbf{NEEDarg10}, NEEDarg11 <NEEDarg12>
\par\end{center}%
\end{minipage}

\smallskip{}

\begin{flushleft}
\textbf{Guide No}: #4.\\
\textbf{Keywords}: #6\\
\par\end{flushleft}
\smallskip%
\end{minipage} & %
\begin{minipage}[c]{1.75in}%
\smallskip{}

\begin{center}
\includegraphics[width=1.75in]{#2}
\par\end{center}{\Huge \par}%
\end{minipage}

\begin{minipage}[c]{1.75in}%
\smallskip{}
\begin{center}
\today
\par\end{center}%
\end{minipage}\tabularnewline
\hline
\end{tabular}
}%%end

\makeatother

\begin{document}

\crmdahdr{logoleft.png}%1
{logoright.png}%2
{A Very Long Title: With a Possibly Long Subtitle}%3
{45}%4
{https://crmda.ku.edu/guides}%5
{\LaTeX, Programming}%6
{Firstname1 Lastname1}%7
{CRMDA}%8
{email1.edu}

Some words here
\end{document}


I realize you need images top left and top right, "logoleft.png" and "logoright.png". If you don't mind, I'll attach blank white image files for that: .

I have one minor question. I took this code out of a bigger project to make the MRE and I cut out lots of packages and other structure. I notice that when I delete the hyperref package, the document doesn't compile without errors anymore.

line 121: Undefined control sequence. {email1.edu}

Why does removing hyperef cause that?

• Sep 13, 2017 at 0:55
– cfr
Sep 13, 2017 at 1:02
• Consider using a key-value interface. They are all the rage and do away with the 9 argument limit. They are much easier to use, make code more readable and you can choose from a number of implementations. If you don't like one implementation, try another. People differ as to which they find intuitive and which they find to be like wading through treacle.
– cfr
Sep 13, 2017 at 1:04
• To echo @cfr's comment, a key-value approach is the way to go, since it provides a human-readable interface for people. The following is very clear: \mycmd{firstname=FirstName,lastname=LastName,...} as opposed to \mycmd{FirstName}{LastName}.... The former can take any order (and is therefore more flexible), while the latter has to have a specific order.
– Werner
Sep 13, 2017 at 1:48
• I want key-value approach. Is "xparse" the right one? What other packages would people recommend instead? I want to avoid the problem that I rely on a package written in 2002 that has some known flaw, but I don't learn about the flaw until a document looks bad and I ask in here how to fix it. Sep 13, 2017 at 13:18

This tidies up the preamble, eliminates the bad boxes and sets up a key-value interface. Keys can either be set separately, ahead of time, or can be set when calling the command, via an optional argument.

If you do this, you should set defaults for all keys and/or configure meaningful error messages.

If you don't use expl3 syntax, note that your code is introducing lots of spurious spaces, some of which may come back to bite you, while the rest haunt your dreams and dance on your grave.

A key-value interface allows as many keys as needed (well, subject to whatever cap TeX imposes on these things), is generally easier to use and makes for cleaner, more readable and easier-to-maintain code. That is, they are all the rage.

\documentclass[11pt,letterpaper,american]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{babel}% surely once is sufficient
\usepackage{parskip}% seems a shame to do this with a KOMA class, but if you must
\usepackage[includehead,includefoot]{geometry}% this stomps all over KOMA's efforts - if you want to use KOMA, use KOMA; otherwise, if you want geometry and stuff, use a standard class [unless you are forced to do otherwise - there are some complex cases, mostly involve US theses, but there you just have to take the view that your document is going to look like crap because the school requires crap for you to graduate]
\usepackage{multicol}
\usepackage{listings}
\usepackage[demo]{graphicx}
\usepackage[yyyymmdd,hhmmss]{datetime}
\usepackage{array,tabularx}
\usepackage{xparse}
% \tabularnewline, \date are defined in core LaTeX
\geometry{% as I say - this is a crappy way to treat a KOMA class
lmargin=1in,
rmargin=1in,
tmargin=0.75in,
bmargin=1.0in,
marginparwidth=0pt,
footskip=1.5\baselineskip,
}

\ExplSyntaxOn
\NewDocumentCommand \crmdasetup { +m }
{
\keys_set:nn { crmda } { #1 }
}
\keys_define:nn { crmda }
{
first ~ author .code:n = {
\keys_set:nn { crmda / first ~ author } { #1 }
},
second ~ author .code:n = {
\keys_set:nn { crmda / second ~ author } { #1 }
},
first ~ author / first ~ name .tl_set:N = \l_crmda_first_first_name_tl,
first ~ author / last ~ name .tl_set:N = \l_crmda_first_last_name_tl,
first ~ author / affiliation .tl_set:N = \l_crmda_first_affil_tl,
first ~ author / email .tl_set:N = \l_crmda_first_email_tl,
second ~ author / first ~ name .tl_set:N = \l_crmda_second_first_name_tl,
second ~ author / last ~ name .tl_set:N = \l_crmda_second_last_name_tl,
second ~ author / affiliation .tl_set:N = \l_crmda_second_affil_tl,
second ~ author / email .tl_set:N = \l_crmda_second_email_tl,
left ~ logo .tl_set:N = \l_crmda_left_logo_tl,
right ~ logo .tl_set:N = \l_crmda_right_logo_tl,
number .int_set:N = \l_crmda_number_int,
title .tl_set:N = \l_crmda_title_tl,
keywords .tl_set:N = \l_crmda_keywords_tl,
url .tl_set:N = \l_crmda_url_tl,
first ~ author .initial:n = { first ~ name = Santa, last ~ name = Claus, affiliation = Toys ~ Research ~ Institute, email = claus@coldmail.com},
second ~ author .initial:n = { first ~ name = Tooth, last ~ name = Fairy, affiliation = Institute ~ of ~ Dentistry, email = toothfairy@smiles.org},
url .initial:n = {https://keys.invensions.bym},
number .initial:n = 42,
title .initial:n = {Guide ~ to ~ Guides},
keywords .initial:n = {guide},
}
\NewDocumentCommand \crmdahdr { +o }
{
\IfValueT { #1 }
{
\keys_set:nn { crmda } { #1 }
}
\crmda_hdr:
}
\cs_new_protected:Nn \crmda_hdr:
{
\noindent
\begin{tabularx}{\textwidth}{|>{\centering\arraybackslash}p{1.25in}>{\centering\arraybackslash}X>{\raggedleft\arraybackslash}p{1.25in}|}
\hline
\begin{minipage}[c]{\linewidth}
\begin{center}
\includegraphics[width=\linewidth]{\l_crmda_left_logo_tl} % no point in have small caps for an image
\par
\end{center}%
\end{minipage} &
\begin{minipage}[c][1\totalheight][b]{3.5in}%
\bigskip
\begin{center}
\begin{minipage}[t][1\totalheight][b]{1\columnwidth}%
\begin{center}
\textbf{ \large \l_crmda_title_tl }\\
\rule[0.5ex]{1\linewidth}{1pt}
\par\end{center}%
\end{minipage}
\par
\end{center}{\Huge \par} % ??!!??
\begin{minipage}[t]{1\columnwidth}
\begin{center}
\textbf{\l_crmda_first_first_name_tl {} ~ \l_crmda_first_last_name_tl}, ~\l_crmda_first_affil_tl {} ~ <\l_crmda_first_email_tl >\\
\textbf{\l_crmda_second_first_name_tl {} ~ \l_crmda_second_last_name_tl}, ~\l_crmda_second_affil_tl {} ~ <\l_crmda_second_email_tl >
\par
\end{center}
\end{minipage}
\smallskip
\par
\begin{flushleft}
\textbf{Guide No}: ~ \int_to_arabic:n { \l_crmda_number_int  } .\\
\textbf{Keywords}: ~ \l_crmda_keywords_tl \\
See ~ \url{\l_crmda_url_tl} ~ for ~ updates.
\par
\end{flushleft}
\smallskip
\end{minipage} &
\begin{minipage}[c]{\linewidth}
\smallskip
\par
\begin{center}
\includegraphics[width=\linewidth]{\l_crmda_right_logo_tl}
\par
\end{center}
{\Huge \par}
\end{minipage}
\par
\begin{minipage}[c]{\linewidth}
\smallskip
\begin{center}
\today
\par
\end{center}
\end{minipage}
\tabularnewline
\hline
\end{tabularx}
}
\ExplSyntaxOff

\begin{document}

\crmdahdr[% use this optional argument or set keys with \crmdasetup{<keys>} beforehand
first author={last name=Lastname1 , first name=Firstname1, affiliation=CRMDA, email=email1.edu},
second author={last name=Lastname2 , first name=Firstname2, affiliation=CRMDB, email=email2.edu},
url={https://crmda.ku.edu/guides},
keywords={\LaTeX, Programming},
title={A Very Long Title: With a Possibly Long Subtitle},
left logo={logoleft},
right logo={logoright},
number=45,
]

Some words here
\end{document}


# EDIT

Here's one way of making the second author optional. I'm not sure I'd do it this way from scratch, but it is a quick way to adapt the existing code.

\documentclass[11pt,letterpaper,american]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{babel}% surely once is sufficient
\usepackage{parskip}% seems a shame to do this with a KOMA class, but if you must
\usepackage[includehead,includefoot]{geometry}% this stomps all over KOMA's efforts - if you want to use KOMA, use KOMA; otherwise, if you want geometry and stuff, use a standard class [unless you are forced to do otherwise - there are some complex cases, mostly involve US theses, but there you just have to take the view that your document is going to look like crap because the school requires crap for you to graduate]
\usepackage{multicol}
\usepackage{listings}
\usepackage[demo]{graphicx}
\usepackage[yyyymmdd,hhmmss]{datetime}
\usepackage{array,tabularx}
\usepackage{xparse}
% \tabularnewline, \date are defined in core LaTeX
\geometry{% as I say - this is a crappy way to treat a KOMA class
lmargin=1in,
rmargin=1in,
tmargin=0.75in,
bmargin=1.0in,
marginparwidth=0pt,
footskip=1.5\baselineskip,
}

\ExplSyntaxOn
\NewDocumentCommand \crmdasetup { +m }
{
\bool_set_false:N \l_crmda_two_authors_bool
\keys_set:nn { crmda } { #1 }
}
\keys_define:nn { crmda }
{
first ~ author .code:n = {
\keys_set:nn { crmda / first ~ author } { #1 }
},
second ~ author .code:n = {
\keys_set:nn { crmda } { two ~ authors }
\keys_set:nn { crmda / second ~ author } { #1 }
},
two ~ authors .bool_set:N = \l_crmda_two_authors_bool,
two ~ authors .default:n = true,
two ~ authors .initial:n = false,
first ~ author / first ~ name .tl_set:N = \l_crmda_first_first_name_tl,
first ~ author / last ~ name .tl_set:N = \l_crmda_first_last_name_tl,
first ~ author / affiliation .tl_set:N = \l_crmda_first_affil_tl,
first ~ author / email .tl_set:N = \l_crmda_first_email_tl,
second ~ author / first ~ name .tl_set:N = \l_crmda_second_first_name_tl,
second ~ author / last ~ name .tl_set:N = \l_crmda_second_last_name_tl,
second ~ author / affiliation .tl_set:N = \l_crmda_second_affil_tl,
second ~ author / email .tl_set:N = \l_crmda_second_email_tl,
left ~ logo .tl_set:N = \l_crmda_left_logo_tl,
right ~ logo .tl_set:N = \l_crmda_right_logo_tl,
number .int_set:N = \l_crmda_number_int,
title .tl_set:N = \l_crmda_title_tl,
keywords .tl_set:N = \l_crmda_keywords_tl,
url .tl_set:N = \l_crmda_url_tl,
first ~ author .initial:n = { first ~ name = Santa, last ~ name = Claus, affiliation = Toys ~ Research ~ Institute, email = claus@coldmail.com},
second ~ author .initial:n = { first ~ name = Tooth, last ~ name = Fairy, affiliation = Institute ~ of ~ Dentistry, email = toothfairy@smiles.org},
url .initial:n = {https://keys.invensions.bym},
number .initial:n = 42,
title .initial:n = {Guide ~ to ~ Guides},
keywords .initial:n = {guide},
}
\NewDocumentCommand \crmdahdr { +o }
{
\group_begin:
\IfValueT { #1 }
{
\bool_set_false:N \l_crmda_two_authors_bool
\keys_set:nn { crmda } { #1 }
}
\crmda_hdr:
\group_end:
}
\cs_new_protected:Nn \crmda_hdr:
{
\noindent
\begin{tabularx}{\textwidth}{|>{\centering\arraybackslash}p{1.25in}>{\centering\arraybackslash}X>{\raggedleft\arraybackslash}p{1.25in}|}
\hline
\begin{minipage}[c]{\linewidth}
\begin{center}
\includegraphics[width=\linewidth]{\l_crmda_left_logo_tl} % no point in have small caps for an image
\par
\end{center}%
\end{minipage} &
\begin{minipage}[c][1\totalheight][b]{3.5in}%
\bigskip
\begin{center}
\begin{minipage}[t][1\totalheight][b]{1\columnwidth}%
\begin{center}
\textbf{ \large \l_crmda_title_tl }\\
\rule[0.5ex]{1\linewidth}{1pt}
\par\end{center}%
\end{minipage}
\par
\end{center}{\Huge \par} % ??!!??
\begin{minipage}[t]{1\columnwidth}
\begin{center}
\textbf{\l_crmda_first_first_name_tl {} ~ \l_crmda_first_last_name_tl}, ~\l_crmda_first_affil_tl {} ~ <\l_crmda_first_email_tl >
\bool_if:NT \l_crmda_two_authors_bool
{
\\
\textbf{\l_crmda_second_first_name_tl {} ~ \l_crmda_second_last_name_tl}, ~\l_crmda_second_affil_tl {} ~ <\l_crmda_second_email_tl >
}
\par
\end{center}
\end{minipage}
\smallskip
\par
\begin{flushleft}
\textbf{Guide No}: ~ \int_to_arabic:n { \l_crmda_number_int  } .\\
\textbf{Keywords}: ~ \l_crmda_keywords_tl \\
See ~ \url{\l_crmda_url_tl} ~ for ~ updates.
\par
\end{flushleft}
\smallskip
\end{minipage} &
\begin{minipage}[c]{\linewidth}
\smallskip
\par
\begin{center}
\includegraphics[width=\linewidth]{\l_crmda_right_logo_tl}
\par
\end{center}
{\Huge \par}
\end{minipage}
\par
\begin{minipage}[c]{\linewidth}
\smallskip
\begin{center}
\today
\par
\end{center}
\end{minipage}
\tabularnewline
\hline
\end{tabularx}
}
\ExplSyntaxOff

\begin{document}

\crmdahdr

\crmdahdr[% use this optional argument or set keys with \crmdasetup{<keys>} beforehand
first author={last name=Lastname1 , first name=Firstname1, affiliation=CRMDA, email=email1.edu},
second author={last name=Lastname2 , first name=Firstname2, affiliation=CRMDB, email=email2.edu},
url={https://crmda.ku.edu/guides},
keywords={\LaTeX, Programming},
title={A Very Long Title: With a Possibly Long Subtitle},
left logo={logoleft},
right logo={logoright},
number=45,
]

\crmdasetup{%
first author={last name=Author , first name=Only, affiliation=CRMDC, email=lone.edu},
url={https://crmda.ku.edu/guides},
keywords={single-authoring, just one},
title={Another Very Long Title: With a Possibly Long Subtitle},
left logo={logoleft},
right logo={logoright},
number=48,
}
\crmdahdr

Some words here
\end{document}


Note that if you use \crmdasetup, the options are set globally, whereas if you pass them in the optional argument to \crmdahdr, they are only set locally within a group.

• Finally, which LaTeX editor are you using? Your indentation is pleasant! Sep 13, 2017 at 13:37
• @pauljohn32 There is no LaTeX 3 yet. However, there are packages which provide some of the stuff developed for LaTeX 3 in LaTeX 2e, so that people can make use of the new facilities (and so they can get tested in real use - but I'm not using any of the experimental 'candidates' here, but only stable stuff). You have uncommented line endings in your macro definition, which TeX reads as spaces. When expl3 syntax is activated, these are ignored (spaces must be added explicitly), but, otherwise, you should comment them unless you want spaces there. I'm using Kile with tweaked indentation.
– cfr
Sep 13, 2017 at 13:43
• I've downloaded your MRE and it runs fine. I'm marking this as the correct answer, but I will need some hand holding to customize. I'm stuck now on how to make the second author optional. Other than that, everything is working in a way I understand. You've given me a Cadillac and all I know how to drive is a bicycle, it seems. Sep 13, 2017 at 17:24
• @pauljohn32 Please see edit above.
– cfr
Sep 13, 2017 at 22:45
• Thanks again, @cfr. I owe you a t-shirt, at least. Send me an address and your size to pauljohn32 at freefaculty.org. Sep 15, 2017 at 13:38

I fiddled with @cfr's code and have a working solution for cases with one, two, or three authors. It is the same solution @cfr proposed, except that I don't use the spaces in key names. Perhaps I'm just too old to look at a left hand side like "last name". That just looks dangerous to me. So I put that as "lastname" and similar to the other ones.

Here's the result:

Code is below. As you see here, this approach does not easily add new authors. It requires copy/paste of stanzas that define the additional authors.. I tried to get a more general approach, using some code I found in the xparse document. I thought I could get an easy fix by optional argument checking with something like this

 \IfNoValueF{\l_guide_second_firstname_tl}{
\textbf{\l_guide_second_firstname_tl {} ~
l_guide_second_lastname_tl}, ~\l_guide_second_affil_tl {} ~
<\l_guide_second_email_tl >\\}


but it never worked. I could not figure out how to set -NoValue- as default for additional authors. Maybe you know how.

I will try to make another MRE test case to explore the more flexible addition of items. Instead of authors in this context, I will think of a class roster that has to easily grow and shrink as students are added or removed. That might be an educational experience for me.

But this works and I'm encouraged to keep trying. Thanks again to @cfr for the help.

\documentclass[11pt,letterpaper,american]{article}
% PJ 20170914: This is my answer to guide with 3 authors
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{babel}% surely once is sufficient
\usepackage{parskip}% seems a shame to do this with a KOMA class, but if you must
\usepackage{multicol}
\usepackage{listings}
\usepackage{graphicx}
\usepackage[yyyymmdd,hhmmss]{datetime}
\usepackage{array,tabularx}
\usepackage{xparse}
\usepackage{ifthen}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=false, bookmarksopen=false,
pdfborderstyle={},backref=false,

\geometry{
lmargin=1in,
rmargin=1in,
tmargin=0.75in,
bmargin=1.0in,
marginparwidth=0pt,
footskip=1.5\baselineskip,
}

\ExplSyntaxOn
\NewDocumentCommand \guidesetup { +m }
{
\bool_set_false:N \l_guide_twoauthors_bool
\bool_set_false:N \l_guide_threeauthors_bool
\keys_set:nn { guide } { #1 }
}
\keys_define:nn { guide }
{
firstauthor .code:n = {
\keys_set:nn { guide / firstauthor } { #1 }
},
secondauthor .code:n = {
\keys_set:nn { guide } { twoauthors }
\keys_set:nn { guide / secondauthor } { #1 }
},
thirdauthor .code:n = {
\keys_set:nn { guide } { threeauthors }
\keys_set:nn { guide / thirdauthor } { #1 }
},
twoauthors .bool_set:N = \l_guide_twoauthors_bool,
twoauthors .default:n = true,
twoauthors .initial:n = false,
threeauthors .bool_set:N = \l_guide_threeauthors_bool,
threeauthors .default:n = true,
threeauthors .initial:n = false,
firstauthor / firstname .tl_set:N = \l_guide_first_firstname_tl,
firstauthor / lastname .tl_set:N = \l_guide_first_lastname_tl,
firstauthor / affiliation .tl_set:N = \l_guide_first_affil_tl,
firstauthor / email .tl_set:N = \l_guide_first_email_tl,
secondauthor / firstname .tl_set:N = \l_guide_second_firstname_tl,
secondauthor / lastname .tl_set:N = \l_guide_second_lastname_tl,
secondauthor / affiliation .tl_set:N = \l_guide_second_affil_tl,
secondauthor / email .tl_set:N = \l_guide_second_email_tl,
thirdauthor / firstname .tl_set:N = \l_guide_third_firstname_tl,
thirdauthor / lastname .tl_set:N = \l_guide_third_lastname_tl,
thirdauthor / affiliation .tl_set:N = \l_guide_third_affil_tl,
thirdauthor / email .tl_set:N = \l_guide_third_email_tl,
leftlogo .tl_set:N = \l_guide_leftlogo_tl,
rightlogo .tl_set:N = \l_guide_rightlogo_tl,
number .int_set:N = \l_guide_number_int,
title .tl_set:N = \l_guide_title_tl,
keywords .tl_set:N = \l_guide_keywords_tl,
url .tl_set:N = \l_guide_url_tl,
firstauthor .initial:n = { firstname = a, lastname = b,
affiliation = c, email = d},
secondauthor .initial:n = { firstname = g, lastname = h,
affiliation = i, email = j},
thirdauthor .initial:n = { firstname = g, lastname = h,
affiliation = i, email = j},
url .initial:n = {https://ku.edu},
number .initial:n = 42,
title .initial:n = {Guide ~ to ~ Guides},
keywords .initial:n = {guide},
}
\NewDocumentCommand \guidehdr { +o }
{
\group_begin:
\IfValueT { #1 }
{
\bool_set_false:N \l_guide_twoauthors_bool
\keys_set:nn { guide } { #1 }
}
\guide_hdr:
\group_end:
}
\cs_new_protected:Nn \guide_hdr:
{
\noindent
\begin{tabularx}{\textwidth}{|>{\centering\arraybackslash}p{1.25in}>{\centering\arraybackslash}X>{\raggedleft\arraybackslash}p{1.25in}|}
\hline
\begin{minipage}[c]{\linewidth}
\begin{center}
\includegraphics[width=\linewidth]{jayhawk.pdf}
\par
\end{center}%
\end{minipage} &
\begin{minipage}[c][1\totalheight][b]{3.5in}%
\bigskip
\begin{center}
\begin{minipage}[t][1\totalheight][b]{1\columnwidth}%
\begin{center}
\textbf{ \large \l_guide_title_tl }\\
\rule[0.5ex]{1\linewidth}{1pt}
\par\end{center}%
\end{minipage}
\par
\end{center}
\begin{minipage}[t]{1\columnwidth}
\begin{center}
\textbf{\l_guide_first_firstname_tl {} ~ \l_guide_first_lastname_tl}, ~\l_guide_first_affil_tl {} ~ <\l_guide_first_email_tl >
\bool_if:NT \l_guide_twoauthors_bool
{
\\
\textbf{\l_guide_second_firstname_tl {} ~ \l_guide_second_lastname_tl}, ~\l_guide_second_affil_tl {} ~ <\l_guide_second_email_tl >
}
\bool_if:NT \l_guide_threeauthors_bool
{
\\
\textbf{\l_guide_third_firstname_tl {} ~ \l_guide_third_lastname_tl}, ~\l_guide_third_affil_tl {} ~ <\l_guide_third_email_tl >
}
\par
\end{center}
\end{minipage}
\smallskip
\par
\begin{flushleft}
{\small{}\textbf{Guide ~ No}: ~ \int_to_arabic:n { \l_guide_number_int  }}\\
\textbf{Keywords}: ~ \l_guide_keywords_tl \\
See ~ \url{\l_guide_url_tl} ~ for ~ updates.
\par
\end{flushleft}
\smallskip
\end{minipage} &
\begin{minipage}[c]{\linewidth}
\smallskip
\par
\begin{center}
\includegraphics[width=\linewidth]{\l_guide_rightlogo_tl}
\par
\end{center}
{\Huge \par}
\end{minipage}
\par
\begin{minipage}[c]{\linewidth}
\smallskip
\begin{center}
\today
\par
\end{center}
\end{minipage}
\tabularnewline
\hline
\end{tabularx}
}
\ExplSyntaxOff

\begin{document}

%% Try just one author:

\guidesetup{%
firstauthor={last name=Author , first name=Only, affiliation=CRMDC, email=lone.edu},
url={https://crmda.ku.edu/guides},
keywords={single-authoring, just one},
title={Another Very Long Title: With a Possibly Long Subtitle},
leftlogo={jayhawk.pdf},
rightlogo={CRMDAlogo-vert.pdf},
number=48,
}
\guidehdr

% Try two authors
\guidesetup{
firstauthor={lastname=Jonas-Smith, firstname=Arthur P.,
affiliation=CRMDA, email=email1@ku.edu},
secondauthor={lastname=Montague, firstname=Wellington P., affiliation=i, email=g},
url={https://crmda.ku.edu/guides},
keywords={\LaTeX, Programming},
title={A Very Long Title: With a Possibly Long Subtitle},
leftlogo={jayhawk.pdf},
rightlogo={CRMDAlogo-vert.pdf},
number=45,
}
\guidehdr

\guidesetup{%
firstauthor={last name=Author , first name=First, affiliation=CRMDC,
email=lone.edu},
secondauthor={lastname=Author, firstname=Second, affiliation=CRMDD, email=g},
thirdauthor={lastname=Author, firstname=Third, affiliation=i, email=g},
url={https://crmda.ku.edu/guides},
keywords={single-authoring, just one},
title={Another Very Long Title: With a Possibly Long Subtitle},
leftlogo={jayhawk.pdf},
rightlogo={CRMDAlogo-vert.pdf},
number=48,
}
\guidehdr

Some words here
\end{document}