# Modify inbook citation when author is same as bookauthor

I have inbook entry where author is the same as bookauthor. By default a bookauthor is omitted in citations in such a case. It can be changed by

\renewbibmacro*{bybookauthor}{%
\printnames{bookauthor}
}


But now we have the same name printed twice. How can I enable idemtracker inside of inbook entry? MWE:

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}

@inbook{mybook,
author={Done, John},
bookauthor={Done, John},
title={Chapter title},
booktitle={Main book title},
crossref={mainbook},
}
\end{filecontents}

\renewbibmacro*{bybookauthor}{%
\printnames{bookauthor}
}

\begin{document}
\cite{mybook}
\end{document}


Result:

Expected result:

UPD:

I've found partial solution:

\renewbibmacro*{bybookauthor}{%
\ifnamesequal{author}{bookauthor}
{\bibstring[\mkibid]{idem\thefield{gender}}%
\setunit{\printdelim{nametitledelim}}}
{\printnames{bookauthor}}


} Or even

\renewbibmacro*{bybookauthor}{%
\ifnamesequal{author}{bookauthor}
{\usebibmacro{cite:idem}}
{\printnames{bookauthor}}}


results: But now the problem is the dot between idem and booktitle. A comma is expected.

• It is usually not expected for an @inbook, but might be possible for @suppbook (which is aliased to @inbook) or in very specific situations that author and bookauthor are not equal (so you wouldn't get an idem), do you want the comma in that case as well or would you want a period? Sep 28 '19 at 10:47
• I thought @suppbook is rather preferred when citing the preface, afterwords etc. In my case it is totally independent chapter. The book himself is a kind of collection of an independent articles (chapters) written by the same author and published as a book. There must be a comma in this place, even if I use some other delimiter between author, title, publisher etc.
– andc
Sep 29 '19 at 11:51
• Sure, the thing is that I wanted to know what would happen if author and bookauthor are not the same (and you get no idem but the full bookauthor), do you want a comma in that case as well or a period? (The comment about @suppbook was just to emphasise that this is not a purely academic question, but a real possibility.) Sep 29 '19 at 11:59
• Oh, sorry, I misunderstood you. In that case (author and bookauthor are not equal) a default blocks delimiter (\newunitpunct) must be used.
– andc
Sep 29 '19 at 13:01

Getting the delimiter right is a bit tricky, because the punctuation tracker usually prints the last punctuation it gets and the drivers add \newunitpunct after executing the bookauthor bibmacro. We can use \printunit instead of the normal \setunit to work around that.

\documentclass{article}

\renewbibmacro*{bybookauthor}{%
\ifnamesequal{author}{bookauthor}
{\bibstring[\mkibid]{idem\thefield{gender}}%
{\printnames{bookauthor}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inbook{mybook,
author     = {Done, John},
bookauthor = {Done, John},
title      = {Chapter title},
booktitle  = {Main book title},
}
\end{filecontents}