Discussion:
[AUCTeX] RefTeX not working well with Biblatex in class file
Tristan Miller
2017-09-07 15:43:01 UTC
Permalink
Dear all,

It seems that RefTeX does not work properly with Biblatex when the
latter is included via a class file rather than directly in the LaTeX
file being edited. In such cases, C-[ doesn't provide the full
list of Biblatex citation commands, and searches only the first
bibliography resource for entries.

For example, consider the following four files:

=== foo.cls:
\NeedsTeXFormat{LaTeX2e}
\LoadClassWithOptions{article}
\ProvidesClass{foo}[2017/09/07 v0.1 test class]
\RequirePackage[backend=biber]{biblatex}

=== foo.tex:
\documentclass{foo}
\addbibresource{bar.bib}
\addbibresource{baz.bib}
\begin{document}
\end{document}

=== bar.bib:
@article{smith,
author = {John Smith},
title = {Smith's Article},
year = 2017,
title = {Smith's Journal},
}

=== baz.bib:
@article{smythe,
author = {Joan Smythe},
title = {Smythe's Article},
year = 2017,
title = {Smythe's Journal},
}


I open foo.tex (using Emacs 25.2 and AUCTeX 11.91) and hit C-[. The
list of citation commands seems awfully short. I hit enter. I'm then
prompted for a regular expression. If I enter "smith" then everything
works fine and the citation is inserted. If I enter "smythe" then I get
the message "No matches found".

On the other hand, if I modify foo.tex so that it directly includes
biblatex with \usepackage, then C-[ gives me the full range of citation
commands, and the search is able to find both "smith" and "smythe".

Is this a known issue? Any way of working around it, short of manually
copying the \RequirePackage[...]{biblatex} from the class file?

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
2017-09-08 07:36:18 UTC
Permalink
Dear all,

On rereading I see some typos had crept into my earlier message.
Instances to "C-[" should instead be "C-c [", and the second "title"
field in the sample .bib files should be "journal".

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Mosè Giordano
2017-09-08 10:04:03 UTC
Permalink
Dear Tristan,
Post by Tristan Miller
Dear all,
It seems that RefTeX does not work properly with Biblatex when the
latter is included via a class file rather than directly in the LaTeX
file being edited. In such cases, C-[ doesn't provide the full
list of Biblatex citation commands, and searches only the first
bibliography resource for entries.
\NeedsTeXFormat{LaTeX2e}
\LoadClassWithOptions{article}
\ProvidesClass{foo}[2017/09/07 v0.1 test class]
\RequirePackage[backend=biber]{biblatex}
\documentclass{foo}
\addbibresource{bar.bib}
\addbibresource{baz.bib}
\begin{document}
\end{document}
@article{smith,
author = {John Smith},
title = {Smith's Article},
year = 2017,
title = {Smith's Journal},
}
@article{smythe,
author = {Joan Smythe},
title = {Smythe's Article},
year = 2017,
title = {Smythe's Journal},
}
I open foo.tex (using Emacs 25.2 and AUCTeX 11.91) and hit C-[. The
list of citation commands seems awfully short. I hit enter. I'm then
prompted for a regular expression. If I enter "smith" then everything
works fine and the citation is inserted. If I enter "smythe" then I get
the message "No matches found".
On the other hand, if I modify foo.tex so that it directly includes
biblatex with \usepackage, then C-[ gives me the full range of citation
commands, and the search is able to find both "smith" and "smythe".
Is this a known issue?
Yes, see the first item of the list of known bugs:
https://www.gnu.org/software/auctex/manual/auctex.html#Bugs
Unfortunately, you can't have two files with the same basename, if you
expect to have a style file for both of them. Thus, you have a style
file for the .tex file, but not for the .cls one. The simplest
workaround is to change the basename of one of them.

Admittedly, this is the single most annoying bug in AUCTeX, and any
fix would be most probably breaking.

Bye,
Mosè
Tristan Miller
2017-09-08 11:38:38 UTC
Permalink
Dear MosÚ,

On Fri, 8 Sep 2017 12:04:03 +0200, MosÚ Giordano
Post by Mosè Giordano
https://www.gnu.org/software/auctex/manual/auctex.html#Bugs
Unfortunately, you can't have two files with the same basename, if you
expect to have a style file for both of them. Thus, you have a style
file for the .tex file, but not for the .cls one. The simplest
workaround is to change the basename of one of them.
I'm not sure I understand what you're saying. The problem I described
is reproducible even if all files have different basenames. (For
example, in the example from my original post, rename the file foo.cls
to quux.cls, and then change the first line of foo.tex to
\documentclass{quux}.)

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Ikumi Keita
2017-09-08 12:53:37 UTC
Permalink
Hi Tristan,
Post by Tristan Miller
I'm not sure I understand what you're saying. The problem I described
is reproducible even if all files have different basenames. (For
example, in the example from my original post, rename the file foo.cls
to quux.cls, and then change the first line of foo.tex to
\documentclass{quux}.)
I suppose you are using a class file which is not supported in vanilla
AUCTeX, i.e., no corresponding style file foo.el or quux.el is in
AUCTeX's style directory, aren't you?

Then you can try generating style file on your own by the following
procedure. I suppose the LaTeX file foo.tex is using quux.cls as its
documentclass.
(1) M-x TeX-auto-generate RET
(2) Select the class file "quux.cls".
(3) Select the directory to store support style file.
Then AUCTeX parses "quux.cls" and saves the relavant information in
"quux.el".
(4) Open the file foo.tex. (If it is opened already, try C-c C-n or C-x
C-v in that buffer.)
(5) Now you can try C-c [. I hope it works as you expected.

Regards,
Ikumi Keita
Tristan Miller
2017-09-08 13:32:08 UTC
Permalink
Dear Ikumi,

On Fri, 08 Sep 2017 21:53:37 +0900, Ikumi Keita
Post by Ikumi Keita
I suppose you are using a class file which is not supported in vanilla
AUCTeX, i.e., no corresponding style file foo.el or quux.el is in
AUCTeX's style directory, aren't you?
Yes, that's right. The class files in question are either ones that
I've authored myself, or else are created by particular
publishers/conferences and not included in major TeX distributions.
Post by Ikumi Keita
Then you can try generating style file on your own by the following
procedure. I suppose the LaTeX file foo.tex is using quux.cls as its
documentclass.
(1) M-x TeX-auto-generate RET
(2) Select the class file "quux.cls".
(3) Select the directory to store support style file.
Then AUCTeX parses "quux.cls" and saves the relavant information
in "quux.el".
(4) Open the file foo.tex. (If it is opened already, try C-c C-n or
C-x C-v in that buffer.)
(5) Now you can try C-c [. I hope it works as you expected.
Thanks -- that procedure worked for the toy quux.cls file, but not for
the more complicated class files I'm actually using. TeX-auto-generate
still failed to detect biblatex. However, from looking at the style
file generate for quux.cls, I am guessing I can just copy the following
lines into the style files for my real class files:

(TeX-add-to-alist 'LaTeX-provided-package-options
'(("biblatex" "backend=biber")))
(TeX-run-style-hooks
"biblatex"))

Regards,
Tristan
--
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Tristan Miller
Free Software developer, ferret herder, logologist
https://logological.org/
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Loading...