joel-coffman / latex-incubator

LaTeX packages that don't have a stable API yet
0 stars 0 forks source link

Publications define labels multiple times in resume #8

Open joel-coffman opened 3 years ago

joel-coffman commented 3 years ago

The \publication macro in the resume package causes the bibliography labels to be multiply defined. For example,

LaTeX Warning: Label `coffman2019diversity' multiply defined.
LaTeX Warning: Label `coffman2014empirical' multiply defined.
LaTeX Warning: Label `cocoros2020evaluating' multiply defined.
...
LaTeX Warning: There were multiply-defined labels.

Although the resume package works correctly (e.g., the redefinition of the label is in the bibliography, which isn't included), there's no reason that such warnings should appear when using the package.

joel-coffman commented 3 years ago

Eliminating the multiply-defined labels is challenging due to the limitations of bibentry. Quoting from its documentation,

The use of both \nobibliography* and \bibliography together is limited and perhaps unsatisfactory. There is only one .bbl file, and hence one list of references. Since \nobibliography* does not have its own list of database files, one cannot take the \bibentry citations from separate databases. Also, any \bibentry citation must appear in the list of references, something that one might reasonably not care for. (It must be in the .bbl file else its text cannot be stored for \bibentry use.)

It would be better if \nobibliography and \bibliography could be used independently of each other, with different databases, different .bbl files. However, this involves enormous complications, with separate .aux files and naming problems for the .bbls.

In particular, some -- but not necessarily all -- bibliography entries are publications. For example, grants and presentations might be formatted using BibTeX and thus appear in the .bbl, but if the labels are not defined in the .bbl file, then LaTeX warns about undefined citations for those entries that aren't also publications. Based on the prior excerpt from bibentry's documentation, either all the entries must be publications (and the labels not defined in the .bbl file) or some set of warnings appears inevitable.

joel-coffman commented 3 years ago

Proof-of-concept that avoids (re)using the bibliography labels:

diff --git a/texmf/tex/latex/resume/resume.sty b/texmf/tex/latex/resume/resume.sty
index 01b9520..49373ca 100644
--- a/texmf/tex/latex/resume/resume.sty
+++ b/texmf/tex/latex/resume/resume.sty
@@ -135,9 +135,18 @@
 }
 \newcounter{c@reference}
 \newcounter{c@publication}
+\renewcommand{\cite}[2][]{[%
+  \def\separator{}%
+  \renewcommand*{\do}[1]{%
+    \separator%
+    \nocite{##1}\ref{publication:##1}%
+    \def\separator{,\penalty\@m\ }% from latex.ltx
+  }%
+  \docsvlist{#2}%
+]}
 \newenvironment{publications}[1]{%
   \newcommand{\publication}[2][]{%
-    \bibitem{##2} \bibentry{##2}
+    \item\label{publication:##2} \bibentry{##2}
     \if\relax\detokenize{##1}\relax%
     \else%
       ({\small ##1\% acceptance rate})%

Redefining \cite regrettably breaks the sorting of citations.