I've been giving a chance to Emacs (with AUCTeX and RefTeX), but I'm still stumbling quite a lot. I've gotten the hang (and appreciated) the RefTeX way to add a citation (as described in, e.g. how to cite using emacs+auctex+reftex). Also, I'm a biblatex user, and recent versions of AUCTeX provide good support for it. However, somehow, how to make this work for biblatex multicite commands (\cites
, \textcites
, \parencites
and so on) completely eludes me.
None of the multicite commands is available out of the box in the reftex-citation
menu C-c [ (though I suppose they could be added without great difficulty). The relevant multicite commands do show up in autocompletion through C-c C-m, but then I do not get the nice regex search in the bib file (as far as I can tell. See more below, it works for regular cite commands but not for multicite).
Furthermore, syntax highlighting (fontification) only recognizes the first key of a multicite command.
Also, RefTeX's reftex-view-crossref
C-c &, does not seem to work with multicite commands, returning "Not on a crossref macro argument".
Related to this, if I want to add an extra bibkey to an already existing multicite command, I also cannot access reftex facilities (with a regular cite command, placing the point before the citation command's closing brace and calling C-c [ would offer me a regex search on the bib files. This can also be used to add a citation key with a command inserted with C-c C-m).
biblatex.el
does seem to include "Support for multicite commands"/"Qualified Citation Lists", but I can't find my way through it.
Am I missing something? Is there a proper "RefTeX way" to deal with biblatex's multicite commands?
In particular:
1 – What would be the normal way (that is, considering default configuration) to add one such command?
2 – How to make these commands recognized by RefTeX, so that reftex-view-crossref
works and new keys can be added with RefTeX facilities after the citation command has already been inserted?
Besides that, but less important:
3 – How to add, e.g. \cites
to RefTeX menu on the call to C-c [?
4 – How to make fontification work for all the keys of a multicite command?
In case someone is willing to play with the relevant settings, a MWE ("biblatex-examples.bib" should be in the same directory as the document, for things to work without further configurations):
\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\cite{sigfridsson}
\parencites{sigfridsson}{knuth:ct}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
[In case it is relevant, I'm using Emacs 24.5 with AUCTeX 12.1.1]
Best Answer
You have many questions here so I try to stay brief. I presume that you have these lines in your init file:
1 - What would be the normal way (that is, considering default configuration) to add one such command?
RefTeX provides the variable
reftex-cite-format
. You can use it for custom query when you hit C-c [. With AUCTeX, you have to setLaTeX-reftex-cite-format-auto-activate
tonil
when settingreftex-cite-format
. In your case, try:in your init file. But I find the input interface in the document cumbersome: You have to do C-c [, s, go through the regex query, mark each entry and hit A. But that's a matter of taste.
2 - How to make these commands recognized by RefTeX, so that reftex-view-crossref works and new keys can be added with RefTeX facilities after the citation command has already been inserted?
This is the tricky part. You have to patch the functions
reftex-figure-out-cite-format
andreftex-view-crossref
. Put this in your init file and restart Emacs; the originalstring-match
lines are commented for your reference:I tried this with this file and you see where it works and where not:
The patches don't work when global optional arguments in
()
are present. Therefore, you have to patch the functionreftex-what-macro
as well; but that would be beyond tex.sx. Please drop a line tobug-auctex@gnu.org
. These issue should be fixed in Emacs 27.3 - How to add, e.g.
\cites
to RefTeX menu on the call to C-c [?Check point 1.
4 - How to make fontification work for all the keys of a multicite command?
I'm afraid this is a "won't fix". Fontification is done by
font-latex.el
shipped with AUCTeX which in general can only fontify fixed number of arguments.