I simply add a publication to the "database" by running a command
\definepublication{name}{header}{title}{authorlist}{journal}
(simplified for the MWE here) defined byCode: Select all
\newcommand\definepublication[5]{% \definepublication{name}{header}{title}{authorlist}{journal}
\expandafter\def\csname #1header\endcsname{#2} % #2 header
\expandafter\def\csname #1title\endcsname{#3} % #3 title
\expandafter\def\csname #1authorlist\endcsname{#4} % #4 authorlist
\expandafter\def\csname #1journal\endcsname{#5} % #5 journal
}
\addcontentsline{toc}{section}{\hspace{-1.6em}<publication-header>}
, where <publication-header>
would be automatically input during calling the macro to insert the front-page. (I have to use \addcontentsline
instead of just letting \chapter{}
handle it, since I want a specific layout in the ToC - details of which are irrelevant here.)So far, I have a macro using
ifthenelse
from the ifthen package to call back to the "database" and output whatever information is wanted (this is also simplified for the MWE),Code: Select all
\newcommand{\publicationlist}[2]{% \publicationlist{name}{what-you-want-out}
% Get the information for the named publication
\def\pubheader{\csname #1header\endcsname}
\def\pubtitle{\csname #1title\endcsname}
\def\pubauthors{\csname #1authorlist\endcsname}
\def\pubjournal{\csname #1journal\endcsname}
% Output what is needed in the form that it should have
\ifthenelse{ \equal{#2}{header} }%
{ \pubheader }{}%
\ifthenelse{ \equal{#2}{text} }%
{ \section*{\pubjournal} \pubauthors \\[2.5mm] ``\pubtitle'' }{}%
}
Code: Select all
\newcommand{\publicationfrontpage}[1]{% \publicationfrontpage{name}
\def\pubchaptername{\publicationlist{#1}{header}}%
\chapter*{\pubchaptername}
\addcontentsline{toc}{section}{\hspace{-1.6em}\pubchaptername}
\publicationlist{#1}{text}
}
Code: Select all
\documentclass{extbook}
\usepackage{ifthen}
<... macros ...>
\begin{document}
\tableofcontents
\definepublication{testarticle}{Publication IV}{title-of-article}{all-of-the-authors}{Journal-name}
\publicationfrontpage{testarticle}
\end{document}
Now the problem is that the
\addcontentsline
macro creates a ton of error messages at compile, but if I replace the \pubchaptername
in there with simple text, or even \testarticleheader
(which is technically what the \def\pubchaptername{\publicationlist{#1}{header}}
calls in the case of that particular publication), there are no errors.Is there something about expansion that I do not understand, or does this go deeper? Thank you so much if you read through all of this and might have a suggestion!

I have attached a full MWE where this error shows up - to make it easier to test on other systems: