Subject: bug#38249: 12.2.0; reftex-create-bibtex-file and biblatex

From: Gustavo Barros <[email-masked]>
Date: Sun, 17 Nov 2019 16:57:37 -0300

Hi all,

`reftex-create-bibtex-file' is a neat RefTeX utility, but it doesn’t 
seem to handle some peculiarities of `biblatex', namely:

- `reftex-all-used-citation-keys', the  auxiliary function used by 
  `reftex-create-bibtex-file' to generate the list of entries cited in 
  the document, does not include entries cited in qualified citation 
  lists.

- `reftex-create-bibtex-file' handles the traditional BibTeX `crossref' 
  and `string' fields, but biblatex extends data inheritance and entry 
  cross-reference with such fields as `xref', `xdata' and `set', which 
  are not taken care of.

A MWE which illustrates these cases is:

#+begin_export latex
\documentclass{article}

\usepackage[minxrefs=1]{biblatex}

\usepackage{filecontents}
\begin{filecontents}{mwe_bib.bib}
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of methods for deriving atomic charges from 
  the electrostatic potential and moments},
  journaltitle = {Journal of Computational Chemistry},
  date         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = 
  {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}

@article{reese,
  author       = {Reese, Trevor R.},
  title        = {Georgia in {Anglo-Spanish} Diplomacy, 1736--1739},
  journaltitle = {William and Mary Quarterly},
  date         = 1958,
  series       = 3,
  volume       = 15,
  pages        = {168-190},
}

@book{companion,
  author       = {Goossens, Michel and Mittelbach, Frank and Samarin, 
  Alexander},
  title        = {The {LaTeX} Companion},
  date         = 1994,
  edition      = 1,
  publisher    = {Addison-Wesley},
  location     = {Reading, Mass.},
  pagetotal    = 528,
}

@incollection{westfahl:space,
  author       = {Westfahl, Gary},
  title        = {The True Frontier},
  subtitle     = {Confronting and Avoiding the Realities of Space in 
  {American} Science Fiction Films},
  pages        = {55-65},
  xref         = {westfahl:frontier},
}

@collection{westfahl:frontier,
  editor       = {Westfahl, Gary},
  title        = {Space and Beyond},
  date         = 2000,
  subtitle     = {The Frontier Theme in Science Fiction},
  publisher    = {Greenwood},
  location     = {Westport, Conn. and London},
}

@xdata{hup,
  publisher    = {Harvard University Press},
  location     = {Cambridge, Mass.},
}

@incollection{pines,
  author       = {Pines, Shlomo},
  editor       = {Twersky, Isadore},
  title        = {The Limitations of Human Knowledge According to 
  {Al-Farabi}, {ibn Bajja}, and {Maimonides}},
  date         = 1979,
  booktitle    = {Studies in Medieval {Jewish} History and Literature},
  xdata        = {hup},
  pages        = {82-109},
  shorttitle   = {Limitations of Human Knowledge},
}

@set{stdmodel,
  entryset     = {glashow,weinberg,salam},
  annotation   = {A \texttt{set} with three members discussing the 
  standard model of particle physics.},
}

@article{glashow,
  author       = {Glashow, Sheldon},
  title        = {Partial Symmetries of Weak Interactions},
  journaltitle = {Nucl.~Phys.},
  date         = 1961,
  volume       = 22,
  pages        = {579-588},
}

@article{weinberg,
  author       = {Weinberg, Steven},
  title        = {A Model of Leptons},
  journaltitle = {Phys.~Rev.~Lett.},
  date         = 1967,
  volume       = 19,
  pages        = {1264-1266},
}

@inproceedings{salam,
  author       = {Salam, Abdus},
  editor       = {Svartholm, Nils},
  title        = {Weak and Electromagnetic Interactions},
  date         = 1968,
  booktitle    = {Elementary particle theory},
  booksubtitle = {Relativistic groups and analyticity},
  booktitleaddon= {Proceedings of the {Eighth Nobel Symposium}},
  eventdate    = {1968-05-19/1968-05-25},
  venue        = {Aspen{\"a}sgarden, Lerum},
  publisher    = {Almquist \& Wiksell},
  location     = {Stockholm},
  pages        = {367-377},
}
\end{filecontents}

\addbibresource{mwe_bib.bib}

\begin{document}

% Entries cited in qualified citation lists are missing in the file 
  generated by `reftex-create-bibtex-file'.
\cites(See, for example)()[45]{sigfridsson}[67]{reese}[24]{companion}.
\textcites(See, for 
example)()[45]{sigfridsson}[67]{reese}[24]{companion}.
\parencites(See, for 
example)()[45]{sigfridsson}[67]{reese}[24]{companion}.

% Entry `westfahl:space' xref's entry `westfahl:frontier'. The latter 
  should be included in the bibliography, given option `minxrefs=1', but 
  it is missing in the file generated by `reftex-create-bibtex-file'.
\cite{westfahl:space}.

% Entry `pines' uses xdata from entry `hup', but the latter is missing 
  in the file generated by `reftex-create-bibtex-file'.
\cite{pines}.

% Set `stdmodel' is composed by entries `glashow', `weinberg' and 
  `salam', wich are missing in the file generated by 
  `reftex-create-bibtex-file'.
\cite{stdmodel}.

\printbibliography{}

\end{document}
#+end_export

The content of the file generated by `reftex-create-bibtex-file' on the 
above MWE is:

#+begin_example
@incollection{westfahl:space,
  author       = {Westfahl, Gary},
  title        = {The True Frontier},
  subtitle     = {Confronting and Avoiding the Realities of Space in 
  {American} Science Fiction Films},
  pages        = {55-65},
  xref         = {westfahl:frontier},
}

@incollection{pines,
  author       = {Pines, Shlomo},
  editor       = {Twersky, Isadore},
  title        = {The Limitations of Human Knowledge According to 
  {Al-Farabi}, {ibn Bajja}, and {Maimonides}},
  date         = 1979,
  booktitle    = {Studies in Medieval {Jewish} History and Literature},
  xdata        = {hup},
  pages        = {82-109},
  shorttitle   = {Limitations of Human Knowledge},
}

@set{stdmodel,
  entryset     = {glashow,weinberg,salam},
  annotation   = {A \texttt{set} with three members discussing the 
  standard model of particle physics.},
}
#+end_example

However, all the entries initially provided are required for the MWE to 
work correctly.

Best regards,
Gustavo Barros.

Emacs  : GNU Emacs 26.3 (build 1, x86_64-pc-linux-gnu, GTK+ Version 
3.22.30)
 of 2019-11-11
Package: 12.2.0

current state:
==============
(setq
 AUCTeX-date "2019-10-31"
 window-system 'x
 LaTeX-version "2e"
 TeX-style-path '("/home/gustavo/.emacs.d/auctex"
                  "/home/gustavo/.emacs.d/elpa/auctex-12.2.0/style"
                  "/home/gustavo/.emacs.d/AUCTeX/auto"
                  "/home/gustavo/.emacs.d/AUCTeX/style" ".auctex-auto"
                  "auctex-style")
 TeX-auto-save t
 TeX-parse-self t
 TeX-master t
 TeX-command-list '(("TeX"
                     "%(PDF)%(tex) %(file-line-error) %`%(extraopts) 
                     %S%(PDFout)%(mode)%' %t"
                     TeX-run-TeX nil (plain-tex-mode ams-tex-mode 
                     texinfo-mode)
                     :help "Run plain TeX")
                    ("LaTeX" "%`%l%(mode)%' %T" TeX-run-TeX nil
                     (latex-mode doctex-mode) :help "Run LaTeX")
                    ("Makeinfo" "makeinfo %(extraopts) %t" 
                    TeX-run-compile nil
                     (texinfo-mode) :help "Run Makeinfo with Info 
                     output")
                    ("Makeinfo HTML" "makeinfo %(extraopts) --html %t"
                     TeX-run-compile nil (texinfo-mode) :help
                     "Run Makeinfo with HTML output")
                    ("AmSTeX" "amstex %(PDFout) %`%(extraopts) 
                    %S%(mode)%' %t"
                     TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
                    ("ConTeXt"
                     "%(cntxcom) --once --texutil %(extraopts) 
                     %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help "Run ConTeXt 
                     once")
                    ("ConTeXt Full" "%(cntxcom) %(extraopts) 
                    %(execopts)%t"
                     TeX-run-TeX nil (context-mode) :help
                     "Run ConTeXt until completion")
                    ("BibTeX" "bibtex %s" TeX-run-BibTeX nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode context-mode)
                     :help "Run BibTeX")
                    ("Biber" "biber %s" TeX-run-Biber nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run Biber")
                    ("View" "%V" TeX-run-discard-or-function t t :help 
                    "Run Viewer")
                    ("Print" "%p" TeX-run-command t t :help "Print the 
                    file")
                    ("Queue" "%q" TeX-run-background nil t :help
                     "View the printer queue" :visible 
                     TeX-queue-command)
                    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Generate PostScript file")
                    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Convert DVI file to PostScript")
                    ("Dvipdfmx" "dvipdfmx %d" TeX-run-dvipdfmx nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Convert DVI file to PDF with dvipdfmx")
                    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Convert PostScript file to PDF")
                    ("Glossaries" "makeglossaries %s" TeX-run-command 
                    nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run makeglossaries to create glossary\n 
                     file")
                    ("Index" "makeindex %s" TeX-run-index nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run makeindex to create index file")
                    ("upMendex" "upmendex %s" TeX-run-index t
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run upmendex to create index file")
                    ("Xindy" "texindy %s" TeX-run-command nil
                     (plain-tex-mode latex-mode doctex-mode ams-tex-mode
                      texinfo-mode)
                     :help "Run xindy to create index file")
                    ("Check" "lacheck %s" TeX-run-compile nil 
                    (latex-mode) :help
                     "Check LaTeX file for correctness")
                    ("ChkTeX" "chktex -v6 %s" TeX-run-compile nil 
                    (latex-mode) :help
                     "Check LaTeX file for common mistakes")
                    ("Spell" "(TeX-ispell-document \"\")" 
                    TeX-run-function nil t
                     :help "Spell-check the document")
                    ("Clean" "TeX-clean" TeX-run-function nil t :help
                     "Delete generated intermediate files")
                    ("Clean All" "(TeX-clean t)" TeX-run-function nil t 
                    :help
                     "Delete generated intermediate and output files")
                    ("Other" "" TeX-run-command t t :help "Run an 
                    arbitrary command")
                    ("make4odt" "make4ht -f odt %t" TeX-run-TeX nil 
                    (latex-mode))
                    ("make4html" "make4ht -uf html5+tidy %t" TeX-run-TeX 
                    nil
                     (latex-mode))
                    ("Arara" "arara --verbose %s" TeX-run-TeX nil t 
                    :help
                     "Run Arara.")
                    )
 )