I am trying to make Tab completion work with RefTeX. When typing C-c [ and selecting the type of reference I have then a prompt in the minibuffer. When I know the beginning of the bib key I want to enter, say for instance Campbell2006
, I would like to type Camp
Tab and get Campbell2006 [sole completion].
I have managed to set it up for some documents but I do not understand exactly why it works for them and not for others. I have noticed that for the documents that have proper Tab> completion, the following line is added to the file name_of_tex_file.el
created in a auto
subfolder:
(TeX-add-style-hook "name_of_tex_file"
(lambda ()
(LaTeX-add-bibliographies
"absolute_path_to_bib")))
I think I obtained this results by adding %%% reftex-default-bibliography: absolute_path_to_bib
at the end of my files but this is kind of a nuisance, especially when editing the same file on several computers.
Note that RefTeX is working because when I type C-c [ Camp
Ret, I get a list (sometime a bit odd) with the Campbell2006 entry.
I have tried to set the %BIBINPUTS% environment variables with no success.
Adding (setq reftex-bibpath-environment-variables '("c:/path_to_bib_file/"))
seemed necessary for the C-c [ Camp
Ret method to work.
It has somehow the same defects as adding a %%% reftex-default-bibliography:
to the end of the file and did not provided the Tab completion.
I have tried various combinations of /
, //
, \\
and \
as file separators when specifying files but I do not know exact which I should use (I'm using emacs in a windows environment). The issue might be as simple as that but as there are lots of parameters to try I fail do determine where is the problem.
What is the step-by-step method to make RefTeX work smoothly with bibliography, including the Tab completion?
EDIT:
Completion is possible according to the Reftex manual entry about the command reftex-citation
:
The regular expression uses an expanded syntax:
&&' is interpreted as and. Thus,
aaaa&&bbb' matches entries which contain bothaaaa' and
bbb'. While entering the regexp, completion on knows [sic] citation keys is possible. `=' is a good regular expression to match all entries in all files.
it does not provide precise guidance on how to make it work though.
Kindahero suggests setting a list of the bib entries and use the completing-read
command. This sounds sensible, however I would like to generate this list automatically and it seems feasible because it works with some of my documents.
TAB
completion, you need to make a list with all your bib entries to make use ofcompleting-read
which indeed by default bound toTAB
– Orvieto=
, then in the selection buffer search for what you need. – Unerring