2

I need to underline all occurrences of a person's name in the bibliography, using ClassicThesis and BibLaTeX. I would prefer to change the tex file only (not the bib or bst). So far, I have tried this and this approach without success. The code for those approaches is reported in the MWE below in commented form.

With the first approach I observe no underline:

first attempt

With the second approach the list of authors is removed:

second attempt

My current setup:

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex 2017.8.23)
Package: biblatex 2016/03/03 v3.3 programmable bibliographies (PK/JW/AB)
Package: classicthesis 2015/09/06 v4.2 Typographic style for a classic-looking 

MWE:

\documentclass{scrbook}

\usepackage{classicthesis}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@article{one,
    author = {Smith, Robert and Garcia, Maria and Johnson, James},
    title = {{Title One}},
    journal = {Journal One},
    year = {2017}
}
@InProceedings{two,
    author = {Garcia, Maria and Smith, Robert and Johnson, James},
    title  = {{Title Two}},
    booktitle = {Conference Two},
    year = {2016}
}
\end{filecontents}

\usepackage[backend=biber, style=alphabetic]{biblatex}
\addbibresource{\jobname.bib}

\usepackage[normalem]{ulem} %for \uline{}

\newcommand{\myLastName}{Smith}

%% solution by Andrzej, https://tex.stackexchange.com/a/31202
% \renewbibmacro*{name:first-last}[4]{%
%   \usebibmacro{name:delim}{#2#3#1}%
%   \usebibmacro{name:hook}{#2#3#1}%
%   \ifthenelse{\equal{#1}{\myLastName}}% 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}}}

%% solution by dardisco, https://tex.stackexchange.com/a/394458
% \DeclareNameFormat{given-family}{
%   \ifgiveninits
%   {\ifthenelse{\equal{\namepartfamily}{\myLastName}}
%     {\uline{\namepartfamily\addspace\namepartgiveni\namepartsuffix}}
%     {\namepartfamily\addspace\namepartgiveni\namepartsuffix}
%     \ifthenelse{\value{listcount} < \value{liststop}}
%     {\addcomma}
%     {\ifthenelse{\ifmorenames}{~et \,al \adddot}}
%     {}
%   }
% }

\begin{document}
\nocite{*}
\printbibliography
\end{document}

Any suggestion?

  • 2
    Do you have to underline, or would bold also be OK? – moewe Jan 30 '18 at 13:30
  • Honestly I would prefer underline, but I just verified that this method for bold works nicely in my setup. Will keep it as a second option, thanks. – Giovanni Saponaro Jan 30 '18 at 14:33
3

Building upon Audrey's answer to Make specific author bold using biblatex we can come up with the following.

\documentclass{article}
\usepackage[backend=biber,maxbibnames=99,defernumbers=true,sorting=ydnt,giveninits=true]{biblatex}

\begin{filecontents}{\jobname.bib}
@InProceedings{identifier1,
  Title                    = {Some Awesome Title},
  Author                   = {Some Author and Another Author},
  Booktitle                = {Some Book about the Future},
  Year                     = {2042},
  Pages                    = {1--42}
}

@InProceedings{identifier2,
  Title                    = {Some So-So Title},
  Author                   = {First Author and Second Author},
  Booktitle                = {An okay Booktitle},
  Year                     = {2000},
  Pages                    = {1--100}
}

  @Book{test1,
  author          = {Goossens, Michel and Mittelbach, Frank
    and Samarin, Alexander},
  title           = {The LaTeX Companion},
  publisher       = {Addison-Wesley},
  location        = {Reading, Mass.},
  year            = {1994},

}

@Book{test2,
  author          = {Mittelbach, F. and Goossens, Michel
    and Samarin, Alexander},
  title           = {The LaTeX Companion},
  publisher       = {Addison-Wesley},
  location        = {Reading, Mass.},
  year            = {1994},

}

@Book{test3,
  author          = {Mittelbach, Frank and Samarin, Alexander
    and Goossens, Michel},
  title           = {The LaTeX Companion},
  publisher       = {Addison-Wesley},
  location        = {Reading, Mass.},
  year            = {1994},
} 
\end{filecontents}
\addbibresource{\jobname.bib}

\def\makenamesetup{%
  \def\bibnamedelima{~}%
  \def\bibnamedelimb{ }%
  \def\bibnamedelimc{ }%
  \def\bibnamedelimd{ }%
  \def\bibnamedelimi{ }%
  \def\bibinitperiod{.}%
  \def\bibinitdelim{~}%
  \def\bibinithyphendelim{.-}}    
\newcommand*{\makename}[2]{\begingroup\makenamesetup\xdef#1{#2}\endgroup}

\newcommand*{\boldname}[3]{%
  \def\lastname{#1}%
  \def\firstname{#2}%
  \def\firstinit{#3}}
\boldname{}{}{}

\boldname{Author}{Some}{S.}

\usepackage[normalem]{ulem}

\makeatletter
\newcommand{\namehighighter}[1]{%
  \ifboolexpr{(test {\ifdefequal{\firstname}{\namepartgiven}}
               or test {\ifdefequal{\firstinit}{\namepartgiven}})
              and test {\ifdefequal{\lastname}{\namepartfamily}}}
    {\uline{#1}}
    {#1}}

\renewbibmacro*{name:given-family}[4]{%
  \usebibmacro{name:delim}{#2#3#1}%
  \usebibmacro{name:hook}{#2#3#1}%
  \namehighighter{%
  \ifdefvoid{#2}{}{\mkbibnamegiven{#2}\isdot\bibnamedelimd}%
  \ifdefvoid{#3}{}{%
    \mkbibnameprefix{#3}\isdot
    \ifprefchar
      {}
      {\ifuseprefix{\bibnamedelimc}{\bibnamedelimd}}}%
  \mkbibnamefamily{#1}\isdot
  \ifdefvoid{#4}{}{\bibnamedelimd\mkbibnamesuffix{#4}\isdot}}}
\makeatother

\begin{document}

\nocite{*}
\printbibliography

\boldname{Goossens}{Michel}{M.}
\printbibliography

\boldname{Mittelbach}{Frank}{F.}
\printbibliography

\end{document}

enter image description here

Note that we did not patch name:given-family, we redefined it. That is because we need a slightly different grouping setup than when using bold text with the \bfseries switch.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.