8

I saw a comment in here that support for multiple addbibresource has been integrated into Emacs. However I'm using a few custom stys from where I require biblatex package with all the necessary parameters.

For some reason in spite of TeX-parse-self set to non-nil, I'm still getting nil for (reftex-using-biblatex-p). I really don't want to move requirement for biblatex out of sty file such that "poor-man's check" for \usepackage would work in reftex-using-biblatex-p. I'd consider it as a last resort.

Is there a workaround to add biblatex into TeX-active-styles? Did I miss something?

Update

Here is an example. Run it once, then open in Emacs, comment out common.sty producing block (select and hit M-;), revisit the file (C-x C-v), and, finally, try C-c [ to add b2016. It won't find it, but will find a2015.

% runme with latexmk -pdf thisfile.tex
\documentclass{article}

\usepackage{filecontents}
\begin{filecontents}{common.sty}
\ProvidesPackage{common}
\RequirePackage[backend=biber,
backref=true,
sorting=nyvt,
url=false,
isbn=false,
doi=true,
eprint=false,
firstinits=true,
mincitenames=3,
maxcitenames=3,
maxbibnames=99,
style=authoryear]{biblatex}
\end{filecontents}

\begin{filecontents}{test1.bib}
@article{a2015,
    title = {Test 1},
    volume = {66},
    pages = {423--430},
    number = {6},
    journaltitle = {Some journal},
    author = {Author, B.C.},
    date = {2015-03-03},
}
\end{filecontents}

\begin{filecontents}{test2.bib}
@article{b2016,
    title = {Test 2},
    volume = {33},
    pages = {123--234},
    number = {2},
    journaltitle = {Another journal},
    author = {Creator, D.E.},
    date = {2016-03-03},
}
\end{filecontents}


\usepackage{common}
\addbibresource{test1.bib}
\addbibresource{test2.bib}

\begin{document}

hello\parencite{b2016}.

\printbibliography
\end{document}

Update 2

The above scenario was tested on 64 bit Emacs 25.0.50.1 and AUCTeX 11.88 on MS Windows. Original value for reftex-bibliography-commands already contains addbibresource.

Update 3

Save the following into startup.el and use emacs -q --load startup.el.

(setq TeX-parse-self t) ; Enable parse on load.
(setq TeX-auto-save t) ; Enable parse on save.
(setq reftex-save-parse-info t) ; I didn't know I had it either in my config
(add-hook 'LaTeX-mode-hook 'reftex-mode)

Apparenty AUCTeX is not involved at all. Also it looks like only real \usepackage{biblatex} results in both bibs in rel file, i.e. filecontents trick with a dummy file won't work. I wonder if AUCTeX affected TeX-active-styles and now only "poor-man's check" work in (reftex-using-biblatex-p).

If you have no \usepackage{biblatex} and no rel file, the latter will be created with only first bib. Once you add \usepackage{biblatex}, it won't affect rel unless you delete it.

  • I'm a bit confused as with this example, I do get biblatex in TeX-active-styles, but things still do not show up in reftex browser. – mlt Mar 3 '15 at 23:03
  • I can confirm RefTeX has some problems, but I think the example should be simplified: load biblatex with a simple \usepackage, don't write a new style file to an external file. I suggest you to report the bug with M-x reftex-report-bug <RET>. – giordano Mar 4 '15 at 11:05
  • I stand corrected: I tested again properly, your example works for me (provided that you create the parsed files for the files generated filecontents) – giordano Mar 5 '15 at 10:12
  • @giordano After running latexmk, delete filecontents blocks, close Emacs, delete all files but filecontents generated ones, make sure to delete thisfile.rel or whatever it was named. I'm 100% positive I can reproduce both bugs individually with emacs-bin-w64-20150217-16d91bc.7z – mlt Mar 5 '15 at 19:54
  • thisfile.rel? Who should generate this file? I followed again your recipe and I cannot reproduce your bug (Emacs 24.4 and AUCTeX 11.88). The relevant configuration you have for RefTeX could help. – giordano Mar 5 '15 at 21:45
4
+50

I'll dare to answer my own question at least regarding workaround for those who need it right here and right now. It drove me nuts that same example worked in one folder and did not in another. And apparently revisiting file doesn't make much difference, so for a clean try, I'd suggest closing Emacs completely.

There are 2 bugs I suspect. One is that reftex fails to recognize biblatex usage when included indirectly. And another one is that reftex fails to properly update rel file (thisfile.rel if you named your original file as thisfile.tex) file regardless where \usepackage{biblatex} is.

There are 2 ways around it. Add that bib file manually into thisfile.rel. Make sure you quit Emacs before doing all that stuff. Due to the bug, it will stay as you edited bib entry there.

Another way is to delete thisfile.rel if it exists, and add \usepackage{biblatex} temporarily so rel file will be recreated on save (provided you enabled TeX-auto-save, but who didn't?). After doing so you'll get ./auto/thisfile.el generated by AUCTeX (?) with biblatex mentioned in it so reftex knows that and can create thisfile.rel. You could also have used filecontents with some dummy file. Once you got all entries in your rel file, you can ditch \usepackage{biblatex} from the main document if you include it somewhere from your styles. After doing this, there will be no biblatex in ./auto/thisfile.el, but bib entry in thisfile.rel won't be recreated either.

Update: The above text was edited to use explicit names rather than \jobname in general sense to avoid confusion. Also it is clarified what is going on in the second workaround regarding ./auto/thisfile.el and biblatex entry.

  • It's true AUCTeX cannot handle properly \jobname, but in your example there is no \jobname, so I cannot understand that point. Instead, it's false AUCTeX cannot recognize \usepackage{biblatex} written in another file, the problem could be there is no auto file associated to it, you have to visit that file and issue C-C- C-n. – giordano Mar 5 '15 at 9:37
  • I should have made it clear about \jobname, I used it as a placeholder since I didn't name example file explicitly aside from thisfile.tex, so it would be thisfile.rel, etc. – mlt Mar 5 '15 at 19:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.