Macro for formatting names (initials or full name)
Here is an idea not using biblatex
at all:
\documentclass{article}
\makeatletter
% define the styles for the first name; these are going to be the values
% for the optional argument of \NewNameType;
% \@style => \NewNameType[style]{<csname>}
\def\@fullname#1\q@stop{#1~}
\def\@initial#1#2\q@stop{#1~}
\def\@initialdot#1#2\q@stop{#1.~}
\def\@noname#1\q@stop{}
% define the user command; the optional arguments sets the format;
% I chose `initial' as default:
\newcommand*\NewNameType[2][initial]{%
\expandafter\newcommand\expandafter*\csname#2\endcsname[1]{\@nameuse{#2@aux}##1\q@stop}%
\@namedef{#2@aux}##1 ##2\q@stop{\@nameuse{@#1}##1\q@stop##2}}
\makeatother
% define some styles:
\NewNameType{researcher} % J Doe
\NewNameType[fullname]{artist} % John Doe
\NewNameType[noname]{baker} % Doe
\NewNameType[initialdot]{musician} % J. Doe
\begin{document}
\researcher{John Doe} \par
\artist{John Doe} \par
\baker{John Doe} \par
\musician{John Doe}
\end{document}
Additional styles could easily be added.
You could add dummy bibentries in your bib
file (and add options = {dataonly=true},
to ensure that they are not included in the bibliography or used for label creation). Based on that, you can use either \citename
as suggested in your question or for convenience create a custom macro (say, \formatname
) that will save you specifying author
as required name list.
\documentclass{article}
\usepackage{biblatex}
\DeclareNameFormat{firstinits-last}{%
\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}%
\usebibmacro{name:andothers}}
\DeclareNameAlias{artist}{first-last}
\DeclareNameAlias{researcher}{firstinits-last}
\newcommand*{\formatname}[2]{%
\citename{fn#1}[#2]{author}%
}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@misc{Doe12,
author = {Doe, John},
year = {2012},
title = {A macro for formatting names},
}
@misc{fnDoe,
options = {dataonly=true},
author = {Doe, John},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}
\begin{document}
\formatname{Doe}{artist}
\formatname{Doe}{researcher}
\printbibliography
\end{document}