diff --git a/patacrep/data/latex/patacrep.sty b/patacrep/data/latex/patacrep.sty index a0919772..cfd54a75 100644 --- a/patacrep/data/latex/patacrep.sty +++ b/patacrep/data/latex/patacrep.sty @@ -407,11 +407,25 @@ % Usage: \indexauthor{First name}{Last name} % Example: \indexauthor{Edgar Allan}{Poe} -\newcommand{\indexauthor}[2]{#2, #1} +% First name can be empty. +\newcommand{\indexauthor}[2]{% + \IfStrEq{#1}{}{% + #2% + }{% + #2, #1% + }% +} % Usage: \indextitle{Article}{Main part} % Example: \indextitle{The}{Raven} -\newcommand{\indextitle}[2]{#2 (#1)} +% Article can be empty +\newcommand{\indextitle}[2]{% + \IfStrEq{#1}{}{% + #2% + }{% + #2 (#1)% + }% +} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/patacrep/index.py b/patacrep/index.py index 63f3058d..5245c329 100755 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -128,8 +128,8 @@ class Index(object): if match: self._raw_add( ( + (match.group(2) + match.group(3)).strip(), match.group(1).strip(), - (match.group(2) + match.group(3)).strip() ), number, link @@ -154,16 +154,13 @@ class Index(object): """ if self.indextype == "AUTHOR": - if key[1]: - return ur"\indexauthor{{{first}}}{{{last}}}".format( - first=key[1], - last=key[0], - ) - else: - return key[0] + return ur"\indexauthor{{{first}}}{{{last}}}".format( + first=key[1], + last=key[0], + ) if self.indextype == "TITLE": - return ur"\indextitle{{{0[0]}}}{{{0[1]}}}".format(key) + return ur"\indextitle{{{0[1]}}}{{{0[0]}}}".format(key) def entry_to_str(self, key, entry): """Return the LaTeX code corresponding to the entry."""