I'm trying to build a glossary from a csv using datatool and \longnewglossaryentry
. I haven't been able to get this to work.
Let's start with something that does compile:
\documentclass[10pt, a4paper]{article}
\usepackage[verbose]{datatool}
\usepackage{filecontents}
\usepackage{hyperref}
\usepackage[nopostdot]{glossaries}
\begin{filecontents*}[overwrite]{test.csv}
Name,Term,Description
"html","Hypertext Markup Language (HTML)","is a markup language"
"css","Cascading Style Sheets (CSS)","is a style sheet language"
\end{filecontents*}
\makeglossaries
\glssetexpandfield{name}
\glssetexpandfield{desc}
\DTLloaddb{data}{test.csv}
\DTLforeach*{data}
{%
\Name=Name,%
\Term=Term,%
\Desc=Description%
}
{%
\newglossaryentry{\Name}{
name={\Term},
description={\Desc}
}%
}
\begin{document}
\glsaddall
\printglossaries
\end{document}
Which renders to this:
Now comes the fun part. I have certain descriptions that have an enumeration in them. If I add the following row to the csv:
"enum","","Enumeration","is a numbered list like \begin{enumerate} \item first \item second \end{enumerate}"
and recompile, I get an error:
[...]
! Incomplete \iffalse; all text was ignored after line 31.
<inserted text>
\fi
[...]
This makes sense since I'm using \newglossaryentry
which doesn't support lists [See update 2, this not be the main issue]. \longnewglossaryentry
does support this, but when I change \newglossaryentry
to \longnewglossaryentry
in my script, I get an error from datatool:
! Package datatool Error: Can't break out of anything.
And that's where I'm stuck.
Update 1
I have seen this format being used for \longnewglossaryentry
as well, where the description is given as the second argument:
\longnewglossaryentry{\Name}{
name={\Term}
}{\Desc}%
In that case, lists do work, but all descriptions will become equal to the last one set.
Update 2
Weirdly enough, when I add the option 'verbose' to datatool (\usepackage[verbose]datatool
), the error has more info, but is also different and actually equal to the error with \newglossaryentry
:
New row added to database `data'
Added Name -> enum to database `data'
Added Term -> Enumeration to database `data'
! Incomplete \iffalse; all text was ignored after line 19.
<inserted text>
\fi
glossaries
(an maybe also indatatool
) recently. I would guess that this error comes from expansion or grouping trouble. Anyhow, I am just a newbie and my skills are by no means sufficient to solve this. – Tomáš Kruliš Jun 11 '20 at 9:06