2

I've created a method to input Norwegian-English translations into a sort of glossary. I need multiple of these little glossaries, later they will be compiled into a big glossary. It doesn't need to be complex.

I use datatool to sort the list alphabetically (ignoring Norwegian indexing problems for now), in a system I'm pretty happy with, actually.

\documentclass[11pt]{memoir}

% \usepackage[colorlinks=true]{hyperref}    % hyperlink to target
\usepackage{multicol}                   % multiple columns
\usepackage{hanging}                    % paragraph indentation control
\usepackage{datatool}                   % for sorting lists

\newcommand{\vocab}[3]{%\parskip=0pt \textbf{#1} (#2) #3~\par%
    \DTLnewrow{vocabsort}%
    \DTLnewdbentry{vocabsort}{norsk}{#1}%
    \DTLnewdbentry{vocabsort}{class}{#2}%
    \DTLnewdbentry{vocabsort}{english}{#3}%
}
\newenvironment{vocabsection}[1]{\noindent \hspace{1em} \textbf{#1} %
    \DTLifdbexists{vocabsort}{\DTLcleardb{vocabsort}}{\DTLnewdb{vocabsort}}%
}% 
{ \dtlsort{norsk}{vocabsort}{\dtlicompare}%
    \displaysorteddb
}
\newcommand{\displaysorteddb}{%
    \begin{multicols}{2}
        \begin{hangparas}{0.5em}{1}
            \begin{DTLenvforeach*}{vocabsort}{\norsk=norsk, \class=class, \english=english}
                \textbf{\norsk} (\class) \english~\par
            \end{DTLenvforeach*}
        \end{hangparas}
    \end{multicols}
}

\begin{document}

    \subsection{Foo}

    \begin{vocabsection}{Map Vocab}     
        \vocab{basseng}{n.}{pool}
        \vocab{hytte}{n.}{cabin} 
        \vocab{akershus}{n.}{A castle in Oslo, the counselors' cabin} 
        \vocab{kjokken}{n.}{kitchen} 
        \vocab{bad}{n.}{bathroom} 
        \vocab{basketball bane}{n.}{basketball court}
        \vocab{lekeplass}{n.}{playground}
        \vocab{sykepleirske}{n.}{nurse's cabin}
        \vocab{innsj\o}{n.}{lake}
        \vocab{skog}{n.}{forest}
        \vocab{vei}{n.}{road} 
        \vocab{flagg}{n.}{flag}
        \vocab{lysthus}{n.}{gazebo}
    \end{vocabsection}

\end{document}

The above code results in this: Working hyperref+multicols

But uncomment \usepackage[colorlinks=true]{hyperref} and it all falls apart, producing:

Broken list

To be honest, I don't need the hyperlinks anyway, since this document will mostly be used in hard copy anyway, but now I'm curious how hypperref could possibly be causing this, and if there is a fix.


As pointed out in the comments, the bug also requires the use of hanging. The question still stands, how could the interaction of hyperref and hanging cause multicols to fail in this instance?

Compile with XeTeX, as it ignores the command-already-defined error produced by hanging.

  • LaTeX can be so bizarre sometimes: I can rearrange a page in minutes, but a package that creates hyperlinks interferes with the output of a sorted and outputted list in two columns. – Azor Ahai -him- Dec 18 '15 at 04:49
  • Your example isn't compilable at the moment, due to hanging package –  Dec 18 '15 at 04:52
  • Oh, I'm compiling it with XeTeX, which gets upset but still compiles – Azor Ahai -him- Dec 18 '15 at 04:53
  • The culprit seems to be \begin{hangparas} in the \displaysorteddb macro. Uncommenting that it will use two columns again, but it doesn't look nice :-( –  Dec 18 '15 at 04:55
  • Noted. But you're right, it's nigh-impossible to read without hanging, especially as these lists will grow larger. – Azor Ahai -him- Dec 18 '15 at 05:12
  • hyperref should be the last (or almost the last, in some cases) package loaded. No idea if that matters here, but as a general rule. – cfr Dec 18 '15 at 05:19
  • @cfr: You're right about the loading of hyperref, unfortunately, it does not cure the problem :-( –  Dec 18 '15 at 06:13
  • @ChristianHupfer As I said, it was a general comment and I had no idea if it mattered here. But loading it early may cause other problems down the line, even if loading it later doesn't resolve this one. So it seemed worth mentioning - that was all. – cfr Dec 18 '15 at 14:06
  • @cfr: I tried loading it at the end before you were commenting, that's why wrote. It would have been nice if our (common) idea of loading it at the end would be successful, but alas ... –  Dec 18 '15 at 15:19

0 Answers0