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{xcolor}% loads color
\usepackage[yyyymmdd,hhmmss]{datetime}
\usepackage{array,tabularx}
\usepackage{xparse}
\usepackage[unicode=true,pdfusetitle, bookmarks=true,bookmarksnumbered=false,bookmarksopen=false, breaklinks=true,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true] {hyperref}
% \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,
headheight=0pt,
headsep=0pt,
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 = [email protected]},
second ~ author .initial:n = { first ~ name = Tooth, last ~ name = Fairy, affiliation = Institute ~ of ~ Dentistry, email = [email protected]},
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{xcolor}% loads color
\usepackage[yyyymmdd,hhmmss]{datetime}
\usepackage{array,tabularx}
\usepackage{xparse}
\usepackage[unicode=true,pdfusetitle, bookmarks=true,bookmarksnumbered=false,bookmarksopen=false, breaklinks=true,pdfborder={0 0 0},pdfborderstyle={},backref=false,colorlinks=true] {hyperref}
% \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,
headheight=0pt,
headsep=0pt,
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 = [email protected]},
second ~ author .initial:n = { first ~ name = Tooth, last ~ name = Fairy, affiliation = Institute ~ of ~ Dentistry, email = [email protected]},
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.
example-image
,example-image-a
,example-image-b
andexample-image-c
as everyone has those.\url
isn't a core macro. You need theurl
orhyperref
packages. Note: you are loading packages more than once. This is bad and should be avoided. Also,hyperref
needs to be loaded late and you are loading it rather early. With a few notable exceptions, it should be last. (cleveref
is a notable exception: it needs to come afterhyperref
.)\renewcommand{\sfdefault}{lmss}
,\renewcommand{\ttdefault}{lmtt}
is pointless. Useparskip
.xcolor
loadscolor
.\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.