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.

9
  • 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 4:49
  • Your example isn't compilable at the moment, due to hanging package – user31729 Dec 18 '15 at 4:52
  • Oh, I'm compiling it with XeTeX, which gets upset but still compiles – Azor Ahai -him- Dec 18 '15 at 4: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 :-( – user31729 Dec 18 '15 at 4: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 5:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.