From 616657acef1ebe980fd61b8d2ec3603a846a9f6e Mon Sep 17 00:00:00 2001 From: Louis Date: Mon, 7 Jul 2014 18:03:30 +0200 Subject: [PATCH] Corrected inversion between first and last name, or article and main title --- patacrep/data/latex/patacrep.sty | 18 ++++++++++++++++-- patacrep/index.py | 15 ++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) 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."""