4

What more do I need to add so that the following source file, with the indicated customized .bbx file will print a horizontal line to replace the author name for subsequent bibliography entries having the same author?

\documentclass[12pt]{memoir}

\usepackage[bibstyle=mybooknumeric,citestyle=numeric,backend=bibtex,,dashed=true]{biblatex}

\begin{filecontents}{euler.bib}
@article{EulerE1776,
    Author = {Euler, Leonhard},Title = {All about E},
    Journal = {Math.\ Psychol.},
    Year = {1776},Volume = {4},number={1},
    pages={1--2718}
}
@article{EulerE1748,
    Author = {Euler, Leonhard},Title = {My formula},
    Journal = {Math.\ Formulas},
    Year = {1748},Volume = {4},
    pages={233--234}
}
\end{filecontents}

\addbibresource{euler.bib}

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

My customized style file:

\ProvidesFile{mybooknumeric.bbx}

\RequireBibliographyStyle{standard}
\RequireBibliographyStyle{numeric}
%
\DeclareBibliographyOption[boolean]{dashed}[true]{%
  \ifstrequal{#1}{true}
    {\ExecuteBibliographyOptions{pagetracker}%
     \renewbibmacro*{bbx:savehash}{\savefield{fullhash}{\bbx@lasthash}}}
    {\renewbibmacro*{bbx:savehash}{}}}
%
\newbibmacro*{bbx:savehash}{%
  \savefield{fullhash}{\bbx@lasthash}}

Here's the output I'm getting now:

Repeated author not replace with horizontal line

lockstep
  • 250,273
murray
  • 7,944
  • The relevant macro is \bibnamedash. – jon Oct 26 '16 at 02:56
  • But how do I get the style to invoke \bibnamedash? And how should that macro be redefined so as to use an underscore (rather than \textemdash or \textendash)? Why isn't the dashed=true being honored: what's wrong with my .bbx there? – murray Oct 26 '16 at 03:12

1 Answers1

6

Here's how it is done in authortitle.bbx, but note that I've only done it for authors, not editors or translators. (You can see how it is done in the .bbx.)

\RequirePackage{filecontents}
\begin{filecontents}{mybooknumeric.bbx}
\ProvidesFile{mybooknumeric.bbx}

\RequireBibliographyStyle{standard}
\RequireBibliographyStyle{numeric}
%
\DeclareBibliographyOption[boolean]{dashed}[true]{%
  \ifstrequal{#1}{true}
    {\ExecuteBibliographyOptions{pagetracker}%
     \renewbibmacro*{bbx:savehash}{\savefield{fullhash}{\bbx@lasthash}}}
    {\renewbibmacro*{bbx:savehash}{}}}
%
\newbibmacro*{bbx:savehash}{%
  \savefield{fullhash}{\bbx@lasthash}}

\renewbibmacro*{author}{%
  \ifboolexpr{
    test \ifuseauthor
    and
    not test {\ifnameundef{author}}
  }
  {\usebibmacro{bbx:dashcheck}
    {\bibnamedash}
    {\printnames{author}%
      \setunit{\addcomma\space}%
      \usebibmacro{bbx:savehash}}%
    \usebibmacro{authorstrg}}
  {\global\undef\bbx@lasthash}}

\newbibmacro*{bbx:dashcheck}[2]{%
  \ifboolexpr{
    test {\iffieldequals{fullhash}{\bbx@lasthash}}
    and
    not test \iffirstonpage
    % NOTE: the follow only matters if you have defined and set up the boolean `bbx@inset` (which is defined in authortitle.bbx).
    % and
    % (
    %   not bool {bbx@inset}
    %   or
    %   test {\iffieldequalstr{entrysetcount}{1}}
    % )
  }
  {#1}
  {#2}}

\end{filecontents}

\begin{filecontents}{euler.bib}
@article{EulerE1776,
    Author = {Euler, Leonhard},Title = {All about E},
    Journal = {Math.\ Psychol.},
    Year = {1776},Volume = {4},number={1},
    pages={1--2718}
}
@article{EulerE1748,
    Author = {Euler, Leonhard},Title = {My formula},
    Journal = {Math.\ Formulas},
    Year = {1748},Volume = {4},
    pages={233--234}
}
\end{filecontents}


\documentclass[12pt]{memoir}

\usepackage[bibstyle=mybooknumeric, citestyle=numeric, backend=bibtex,,dashed=true]{biblatex}
\addbibresource{euler.bib}

\renewcommand*{\bibnamedash}{\rule{3em}{0.4pt}\hskip 0.16667em plus 0.01em minus 0.002em\relax \addcomma} 

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

simple bibnamedash example

jon
  • 22,325
  • Probably better (and closer to amsplain style with just bibtex), something like: \renewcommand*{\bibnamedash}{\rule{3em}{0.4pt}\hspace*{.16667em}\addcomma\addspace}. I'd like to make the space after the rule have a rubber length but don't know how (\hskip doesn't seem to work there). – murray Oct 26 '16 at 14:59
  • \hskip will work. What do you want as your values? – jon Oct 26 '16 at 19:37
  • Probably something close to \hskip 0.16667em plus 0.01em minus 0.002em – murray Oct 30 '16 at 20:05
  • Will edit. But who will be able to notice this small a strech value? That's a about a plus 0.004 cm minus 0.0008 cm range for a skip that is already only about 0.7 cm wide.... – jon Oct 31 '16 at 04:27