[Tex/LaTex] biblatex formatting

biblatex

I'm preparing my CV in latex using a slightly modified template with respect to the one found here. I like it very much, in particular the fact that the bibliography can be splitted into several types of contribution. I've have also applied the trick described here by Andrzej. The problem is that the first author in the bibliography is formatted differently from the others, as Surname, Initial, SecondAuthorInitial Surname. So the trick that applies to underline my name does not apply to all the entries where I'm the first author. I would like to change the way the first author appears in order to be compliant with the other. So in this way I think that the trick for the underlining should work.

As asked I post the code relating to the bibliography setting

\documentclass[a4paper,11pt]{article}
\usepackage[sorting=ynt,bibstyle=authoryear-comp,labelyear=false,labelyear=false,defernumbers=true,maxnames=100,uniquename=init,backend=bibtex8,dashed=false,arxiv=abs]{biblatex}
\DeclareFieldFormat{url}{\url{#1}}
\DeclareFieldFormat[article]{pages}{#1}
\DeclareFieldFormat[inproceedings]{pages}{\lowercase{pp.}#1}
\DeclareFieldFormat[incollection]{pages}{\lowercase{pp.}#1}
\DeclareFieldFormat[article]{volume}{\textbf{#1}}
\DeclareFieldFormat[article]{number}{(#1)}
\DeclareFieldFormat[article]{title}{\MakeCapital{#1}}
\DeclareFieldFormat[inproceedings]{title}{#1}
\DeclareFieldFormat{shorthandwidth}{#1}
\DeclareBibliographyDriver{article}{%
\usebibmacro{bibindex}%
\usebibmacro{begentry}%
\usebibmacro{author/editor}%
\setunit{\labelnamepunct}\newblock
\MakeSentenceCase{\usebibmacro{title}}%
\newunit
\printlist{language}%
\newunit\newblock
\usebibmacro{byauthor}%
\newunit\newblock
\usebibmacro{byeditor+others}%
\newunit\newblock
\printfield{version}%
\newunit\newblock
%  \usebibmacro{in:}%
\usebibmacro{journal+issuetitle}%
\newunit\newblock
\printfield{note}%
\setunit{\bibpagespunct}%
\printfield{pages}
\newunit\newblock
\printfield{issn}%
\newunit\newblock
\printfield{doi}%
\newunit\newblock
\usebibmacro{eprint}
%\newunit\newblock
%\usebibmacro{url+urldate}%
\newunit\newblock
\printfield{addendum}%
\newunit\newblock
\usebibmacro{pageref}%
\usebibmacro{finentry}}

% Remove dot between volume and number in journal articles.
\renewbibmacro*{journal+issuetitle}{%
\usebibmacro{journal}%
\setunit*{\addspace}%
\iffieldundef{series}
{}
{\newunit
 \printfield{series}%
 \setunit{\addspace}}%
 \printfield{volume}%
 %\setunit*{\adddot}%
 \printfield{number}%
 \setunit{\addcomma\space}%
 \printfield{eid}%
 \setunit{\addspace}%
 \usebibmacro{issue+date}%
 \newunit\newblock
 \usebibmacro{issue}%
 \newunit}


 %added a trick to underline my surname
\renewbibmacro*{name:first-last}[4]{%
\usebibmacro{name:delim}{#2#3#1}%
\usebibmacro{name:hook}{#2#3#1}%
\ifthenelse{\equal{#1}{Vianello}}% matches last name against YourLastName
{
  \uline{% wrapped with \uline
  \ifblank{#2}{}{\mkbibnamefirst{#2}\isdot\bibnamedelimd}%
  \ifblank{#3}{}{%
    \mkbibnameprefix{#3}\isdot%
    \ifpunctmark{'}%
      {}%
      {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
  \mkbibnamelast{#1}\isdot%
  \ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}}}%
{% original
  \ifblank{#2}{}{\mkbibnamefirst{#2}\isdot\bibnamedelimd}%
  \ifblank{#3}{}{%
    \mkbibnameprefix{#3}\isdot%
    \ifpunctmark{'}%
      {}%
      {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
  \mkbibnamelast{#1}\isdot%
  \ifblank{#4}{}{\bibnamedelimd\mkbibnameaffix{#4}\isdot}}}
  \usepackage{filecontents}

  \begin{filecontents}{biblio.bib}
   @article{PhysRevLett.106.125002,
   author = {Vianello, Nicola and Naulin, V and Schrittwieser, R and M uller, H. W. and    Zuin, M and Ionita, C and Rasmussen, J J and Mehlmann, F and Rohde, V and Cavazzana, R and Maraschek, M},
   title = {{Direct Observation of Current in Type-I Edge-Localized-Mode Filaments on the     ASDEX Upgrade Tokamak}},
   journal = {Physical Review Letters},
   year = {2011},
   volume = {106},
   number = {12},
   pages = {125002},
   month = mar
   }
  \end{filecontents}

  \addbibresource{biblio.bib}
  \begin{document}
  \nocite{*}
  \printbibliography
  \end{document}

Now I think the example should work once one provides a biblio.bib file (any bibliographic file you have should work. The only trick is the surname you chose, mine being Vianello)
I apologize for the problems in the example provided.

Best Answer

To manipulate the output of the names you have to set sortname in the correct way.

\DeclareNameAlias{sortname}{last-first}

In this case the first name beside the first author is printed as initial.

To modify this you have to define your own formatting directives via \DeclareNameFormat.

A simple example is given by the definition of last-first (see biblatex.def):

\DeclareNameFormat{last-first}{%
  \iffirstinits
    {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
    {\usebibmacro{name:last-first}{#1}{#3}{#5}{#7}}%
  \usebibmacro{name:andothers}}

The arguments have the following meaning:

% #1 = last name
% #2 = last name (initials)
% #3 = first name
% #4 = first name (initials)
% #5 = name prefix, a.k.a. 'von part'
% #6 = name prefix (initials)
% #7 = name affix, a.k.a. 'junior part'
% #8 = name affix (initials)

In this case you can format the name lists.

If you want to handle the first author in a special way you can use the test

\ifnumequal{\value{listcount}}{1}
  {ONLY FIRST AUHTOR}
  {ALL OTHER AUTHORS}

For example If you want to underline the first author of the list and the name list is formated as last name, first name (initials) you can do:

\usepackage[normalem]{ulem}

\DeclareFieldFormat{FirstAuthor}{\uline{#1}}

\DeclareNameFormat{last-first-underline}{%
    \ifnumequal{\value{listcount}}{1}
      {
       {\printtext[FirstAuthor]{\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}}
      }%
      {
       {\usebibmacro{name:last-first}{#1}{#4}{#5}{#7}}
      }%
      \usebibmacro{name:andothers}}