Hi kalle1,
The acronym and glossaries (acro, acronym, glossaries...) packages do such things but I don't believe that they're perfectly suited for your needs. It is possible without too much hassles to define such macros yourself. One way would be to define a boolean on a per-name basis that is set to true on the first use and use a different formatting depending on the state of the boolean.
Here is a preliminary code example that implements
\newauthor{<id>}{<first name>}{<last name>}
that defines a name, and
\useauthor{<id>}
that prints the full defined name as well as
\useauthor*{<id>}
which only prints the last name. I tried to separate usage from formatting so a few simple macros are defined for the formatting where you can choose a formatting you deem best.
Code: Select all
\documentclass{article}
% a font that has italic small caps:
\usepackage[T1]{fontenc}
\usepackage{libertine}
% programming tools:
\usepackage{etoolbox}
\makeatletter
% user level command for defining authors:
\newrobustcmd\newauthor[3]{%
\kalle@new@author{#1}{#2}{#3}%
}
% internal command for defining authors:
\def\kalle@new@author#1#2#3{%
% boolean to detrmine first and further use:
\newbool{kalle@author@#1@used}%
% un-starred variant typesets the full name:
\csdef{kalle@author@#1@nostar}{%
\ifbool{kalle@author@#1@used}
{% further use:
\begingroup
\kalle@further@format
#2 {\kalle@last@name@format#3}%
\endgroup
}
{% first use:
\booltrue{kalle@author@#1@used}%
\begingroup
\kalle@first@format
#2 {\kalle@last@name@format#3}%
\endgroup
}%
}%
% starred variant typesets only the last name:
\csdef{kalle@author@#1@star}{%
\ifbool{kalle@author@#1@used}
{% further use:
\begingroup
\kalle@further@format
\kalle@last@name@format
#3%
\endgroup
}
{% first use:
\booltrue{kalle@author@#1@used}%
\begingroup
\kalle@first@format
\kalle@last@name@format
#3%
\endgroup
}%
}%
}
% user level for using an author:
\newrobustcmd\useauthor{%
\kalle@use@author
}
% internal command for using an author; call the last or the full name
% depending on an optional star:
\def\kalle@use@author{%
\@ifstar
{\kalle@use@author@star}
{\kalle@use@author@nostar}%
}
\def\kalle@use@author@star#1{%
\csuse{kalle@author@#1@star}
}
\def\kalle@use@author@nostar#1{%
\csuse{kalle@author@#1@nostar}
}
% define the initial formats of first and further use, also a special
% formatting for the last name:
\def\kalle@first@format{\itshape}
\def\kalle@further@format{\upshape}
\def\kalle@last@name@format{\scshape}
\makeatother
\newauthor{lastname}{Firstname R.\@}{Lastname}
\newauthor{doe}{John}{Doe}
\begin{document}
first \useauthor{lastname} and later \useauthor{lastname}
first \useauthor*{doe} and later \useauthor*{doe}
\end{document}

- authors.png (12.43 KiB) Viewed 3554 times
Regards