4

I am trying to make a more automatic latex CV. I'd like my reference section to lead with: "Refereed Publications (N first author, M total):"

For the M total, I have found a solution based on this post:

\usepackage{totcount}

\newtotcounter{citnum} %From the package documentation
\def\oldbibitem{} \let\oldbibitem=\bibitem
\def\bibitem{\stepcounter{citnum}\oldbibitem}

\renewcommand{\refname}{Refereed Publications [N first author, \total{citnum} total]:}

This results in the heading for the Bibliography section being changed to Refereed Publications [9 first author, 45 total]:, where the number 9 in this example is hard-coded and the number 45 has been counted by latex.

How can I do the same sort of counting, but only for the N publications on which I am the first author?

MWE added as per Johannes_B's request:

\documentclass{article}
\usepackage{natbib}
\usepackage{totcount}

\newtotcounter{citnum} %From the package documentation
\def\oldbibitem{} \let\oldbibitem=\bibitem
\def\bibitem{\stepcounter{citnum}\oldbibitem}

\renewcommand{\refname}{Refereed Publications [2 first author, \total{citnum} total]:}

\begin{document}
\nocite{*}
\bibliographystyle{apj_revchron}
\bibliography{mwe}
\end{document}

With the bib file mwe.bib:

@article{one,
    author = {{me}, a. and {you}, b.},
    title = {one},
    journal = {one},
    year = {2015},
}
@article{two,
    author = {{you}, a. and {me}, b.},
    title = {two},
    journal = {two},
    year = {2015},
}
@article{three,
    author = {{me}, a. and {you}, b. and {them}},
    title = {three},
    journal = {three},
    year = {2015},
}

This will result in the heading: Refereed Publications [2 first author, 3 total]: My question is, how can the 2 here be automatically determined?

7
  • Hi there, i really don't understand what you want. Can you extend the question/explanation and add a working example?
    – Johannes_B
    Jan 6, 2016 at 9:49
  • Johannes_B: I want to count the number of publications cited that have a specific first author. Counting the total number of cited publications is demonstrated in the example.
    – keflavich
    Jan 6, 2016 at 11:42
  • "Can you extend the question/explanation and add a working example?" The question is that big thing above your picture, not a comment.
    – Johannes_B
    Jan 6, 2016 at 11:44
  • I cannot add a working example - I do not know how to implement this. I'll extend the question, though.
    – keflavich
    Jan 6, 2016 at 11:46
  • A minimal working example lets us reproduce what you are trying. Are you using natbib? jurabib? biblatex? cite? any package at all?
    – Johannes_B
    Jan 6, 2016 at 11:47

1 Answer 1

5

Here a solution mostly stolen from Audrey in Count number of references using biblatex

keflavichCountCites

%\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
    @article{one,
        author = {Bee, B. and Wombat, W.},
        title = {Loving cobblestone},
        journal = {Stones weekly},
        year = {2015},
        keywords = {mefirst},
    }
    @article{two,
        author = {Wombat, W. and Bee, B.},
        title = {Flying Penguins},
        journal = {MP Monthly},
        year = {2015},
    }
    @article{three,
        author = {Bee, Busy and Wombat, Walzing and Penguins},
        title = {Animal Friendships},
        journal = {Madagascar Quarterly},
        year = {2015},
        keywords = {mefirst},
    }
\end{filecontents}
\documentclass{article}
\usepackage{biblatex}
\addbibresource{\jobname.bib}


\defbibheading{bibliography}[]{\section*{Refereed Publications}
\arabic{firstA} as first author, a total of \arabic{sum}\medbreak
}
\newcounter{firstA}
\newcounter{notfirst}
\AtDataInput{%
    \ifboolexpr{ test {\ifkeyword{mefirst}} }
    { \stepcounter{firstA} }
    { \stepcounter{notfirst} }%
}
\newcounter{sum}

\begin{document}
\defcounter{sum}{\value{firstA}+\value{notfirst}}
\nocite{*}
\printbibliography
\end{document}
6
  • This requires biblatex, right? I am using natbib. It seems that either natbib and biblatex are incompatible and/or my style file is incompatible with biblatex.
    – keflavich
    Jan 6, 2016 at 16:58
  • @keflavich Yes, biblatex replaces natbib and the bst files you are having. Since you bst looks like a usual numeric style, i didn't bother. Personally, i don't use BibTex and related packages, because making changes is a pure pain (as already mentioned).
    – Johannes_B
    Jan 6, 2016 at 17:04
  • I get errors I found no \citation commands and no \bibdata, \bibstyle when I run your example. Is there something missing?
    – keflavich
    Jan 6, 2016 at 17:13
  • 1
  • It looks like this approach works if I use biblatex & biber, but that is not an option for me at present since I already have a painstakingly customized .bst file and no time to develop a corresponding style file for biblatex. If it is impossible to do what I want with bibtex, then I'll eventually accept this answer, but I am hoping for a solution that uses bibtex.
    – keflavich
    Jan 6, 2016 at 17:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .