diff --git a/patacrep/authors.py b/patacrep/authors.py index 32afb09a..769f2090 100644 --- a/patacrep/authors.py +++ b/patacrep/authors.py @@ -168,10 +168,10 @@ def processauthors_invert_names(authors_list): for author in authors_list: first, last = split_author_names(author) if first: - dest.append("%(last)s, %(first)s" % { - 'first': first.lstrip(), - 'last': last.lstrip(), - }) + dest.append(r"\indexauthor{{{first}}}{{{last}}}".format( + first=first.strip(), + last=last.strip(), + )) else: dest.append(last.lstrip()) return dest diff --git a/patacrep/data/latex/patacrep.sty b/patacrep/data/latex/patacrep.sty index d070ec2b..084e5866 100644 --- a/patacrep/data/latex/patacrep.sty +++ b/patacrep/data/latex/patacrep.sty @@ -402,4 +402,17 @@ } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Title and author rendering in the index + +% Usage: \indexauthor{First name}{Last name} +% Example: \indexauthor{Edgar Allan}{Poe} +\newcommand{\indexauthor}[2]{#2, #1} + +% Usage: \indextitle{Article}{Main part} +% Example: \indextitle{The}{Raven} +\newcommand{\indextitle}[2]{#2 (#1)} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + \endinput diff --git a/patacrep/index.py b/patacrep/index.py index 1420272b..cd83668e 100755 --- a/patacrep/index.py +++ b/patacrep/index.py @@ -128,13 +128,13 @@ class Index(object): match = pattern.match(key.encode('utf-8')) if match: self._raw_add( - "{} ({})".format( - match.group(2) + match.group(3), - match.group(1) - ), - number, - link - ) + r"\indextitle{{{}}}{{{}}}".format( + match.group(1).strip(), + (match.group(2) + match.group(3)).strip(), + ), + number, + link + ) return self._raw_add(key, number, link)