2

For my Phd thesis, I'm using the glossaries package from Nicola Talbot to create multiple glossaries - including a list of court decisions that I've cited within the thesis.

In the mentioned list of court decisions, I want them to be sorted by the name of the court and the decision date (given format: DD.MM.YYYY). Therefore, I create a sort key using the xstring package (formatted "Court-YYYY-MM-DD") and pass it as sort key in the \newglossaryentry command (via my macro called \decision{key}{shortinfo}{longinfo}).

The sort keys in the below example are:

BGH-2000-12-08
BGH-2003-01-09
BGH-2010-10-05 

I makeindex using the following bash script within my latex engine

for file in *-glo ; do
makeindex -t ${file%-glo}-glg -s $docname.ist -o ${file%-glo}-gls $file
done

Unfortunately, the printed decision glossary seems to ignore the sort keys. It seems that the decision entries are still being sorted by just using the glossary entry description.

The output of the below minimal example shows as

BGH, Urteil vom 05.10.2010, Az. V ZR 228/09, Online-Entscheidungsdatenbank des BGH. 
BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH. 
BGH, Urteil vom 09.01.2003, Az. VII ZR 181/00, NJW 2003, 1188.

instead of

BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH. 
BGH, Urteil vom 09.01.2003, Az. VII ZR 181/00, NJW 2003, 1188.
BGH, Urteil vom 05.10.2010, Az. V ZR 228/09, Online-Entscheidungsdatenbank des BGH. 

Minimal example:

\usepackage{xstring}    
\usepackage[toc=true]{glossaries}
\newglossary[decision-glg]{decision}{decision-gls}{decision-glo}{Decisions}
\makeglossaries

% Macro to create sort key
\newcommand{\getCourt}[1]{\StrBefore[1]{#1}{,}}
\newcommand{\getYear}[1]{\StrBetween[2,2]{#1}{.}{,}}
\newcommand{\getMonth}[1]{\StrBetween[1,2]{#1}{.}{.}}
\newcommand{\getDay}[1]{\StrBetween[1,1]{#1}{vom }{.}}
\newcommand{\getsortstring}[1]{\getCourt{#1}-\getYear{#1}-\getMonth{#1}-\getDay{#1}}
\newcommand{\justprint}[1]{#1}

% Manipulate sorting
\let\courtdate\justprint
\renewcommand{\glsprestandardsort}[3]{%
    \ifdefstring{#2}{decision}{%
        \let\courtdate\getsortstring%
        \edef#1{\expandafter\expandonce\expandafter{#1}}%
        \let\courtdate\justprint%
        \glsdosanitizesort%
    }{%
        \glsdosanitizesort%
    }%
}

% Macro to add decisions as glossary entry: \decision{key}{shortinfo}{longinfo}
\newcommand{\decision}[3]{%
    \newglossaryentry{#1}{type=decision, name={#2}, description={#3}, sort={\getsortstring{#3}}}%
}

% Create new style for the glossary
\newglossarystyle{decisionlist}{%
  \renewenvironment{theglossary}{\begin{spacing}{1.5}}{\end{spacing}}%
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
  \renewcommand*{\glossentry}[2]{%
    \noindent% No left padding
    \textbf{% Make bold
        \StrBefore{\glossentrydesc{##1}}{,}% Insert court name
    },% Add comma
    \StrBehind{\glossentrydesc{##1}}{,}.% Insert decision info
    \\}% Insert newline after entry
  \renewcommand*{\subglossentry}[3]{}%
  \renewcommand*{\glsgroupskip}{}%
} 

% Add decisions as glossary entries using the above macro
\decision{BGH, V ZR 482/99}{BGHZ-Online, V ZR 482/99}{BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}
\decision{BGH, VII ZR 181/00}{BGH, NJW 2003, 1188}{BGH, Urteil vom 09.01.2003, Az. VII ZR 181/00, NJW 2003, 1188}
\decision{BGH, V ZR 228/09}{BGHZ-Online, V ZR 228/09}{BGH, Urteil vom 05.10.2010, Az. V ZR 228/09, Online-Entscheidungsdatenbank des BGH}

\begin{document}

\setglossarystyle{decisionlist}
\printglossary[type=decision]

I am citing all of the above decisions. Those are \gls{BGH, V ZR 482/99}, \gls{BGH, V ZR 228/09} and \gls{BGH, VII ZR 181/00}.

Since I'm trying for ages now, to sort out, why the entries are displayed in the wrong order despite me passing the sort keys, I'd be more than happy if someone could lead the way :)

1 Answer 1

1

If you look at the .decision-glo file, you can see the value of the sort key. The first line is:

\glossaryentry{\getCourt {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}-\getYear {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}-\getMonth {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}-\getDay {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}?\glossentry{BGH, V ZR 482/99}|setentrycounter[]{page}\glsnumberformat}{1}

So the sort value hasn't been expanded. We can add some \show code to find out what's happening:

\renewcommand{\glsprestandardsort}[3]{%
    \ifdefstring{#2}{decision}{%
        \let\courtdate\getsortstring%
\show#1%
        \edef#1{\expandafter\expandonce\expandafter{#1}}%
\show#1%
        \let\courtdate\justprint%
        \glsdosanitizesort%
    }{%
        \glsdosanitizesort%
    }%
}

The first \show#1 produces:

> \@glo@sort=macro:
->\getsortstring {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheid
ungsdatenbank des BGH}.

and the second produces:

> \@glo@sort=macro:
->\getCourt {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online-Entscheidungsd
atenbank des BGH}-\getYear {BGH, Urteil vom 08.12.2000, Az. V ZR 482/99, Online
-Entscheidungsdatenbank des BGH}-\getMonth {BGH, Urteil vom 08.12.2000, Az. V Z
R 482/99, Online-Entscheidungsdatenbank des BGH}-\getDay {BGH, Urteil vom 08.12
.2000, Az. V ZR 482/99, Online-Entscheidungsdatenbank des BGH}.

So the expansion is going awry here. If the argument of \getsortstring is always in the form Court, Urteil vom dd.mm.yyyy,remaining then here's another approach:

\def\parsesortstring#1,#2vom #3.#4.#5,#6\endparsesortstring{#1-#5-#4-#3}
\newcommand{\getsortstring}[1]{\parsesortstring#1\endparsesortstring}

% Manipulate sorting
\let\courtdate\justprint
\renewcommand{\glsprestandardsort}[3]{%
    \ifdefstring{#2}{decision}{%
    }{%
        \glsdosanitizesort%
    }%
}

This simply removes \glsdosanitizesort for the decision type, allowing the sort value to fully expand when it's written to the external file. The first line of .decision-glo is now:

\glossaryentry{BGH-2000-12-08?\glossentry{BGH, V ZR 482/99}|setentrycounter[]{page}\glsnumberformat}{1}

which has the correct sort value BGH-2000-12-08.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .