Hot answers tagged

17

To skip the selection of the reference style you have to set the variable reftex-ref-macro-prompt to nil, see the RefTeX manual. To do this you can customize that variable or add the following code to your init file: (setq reftex-ref-macro-prompt nil) It has been reported that this solution to use RefTeX with the cleverref package no longer works with ...


13

Adding %%% reftex-default-bibliography: ("path/to/bibfile.bib") at the end of my file with other commands related to the file looks better to me.


12

Add the following code to your init file (eval-after-load "latex" '(TeX-add-style-hook "cleveref" (lambda () (if (boundp 'reftex-ref-style-alist) (add-to-list 'reftex-ref-style-alist '("Cleveref" "cleveref" (("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D))))) (reftex-ref-style-activate "...


12

Like for any other macro you want to insert in AUCTeX, you should use C-c RET cite RET (or C-c C-m cite RET; for more information about autocompletion in AUCTeX see the quick start or Completion section of the manual). This works also for all other citation macros provided by natbib, biblatex, ect... (\citep, \citealt, \parencite, \textcite, etc...) For ...


8

The issues you're experiencing are not related to emacs, and they are only indirectly related to cleveref. You need to do the following: In the main figure, interchange the order of \caption and \label: the \caption statement must come before the \label statement. Provide \caption statements for each of the two subfigure environments. Be mindful of the fact ...


8

You can set a master file (main.tex). Thus you can include the following in all .tex files in your project. %%% Local Variables: %%% mode: latex %%% TeX-master: "main" %%% End: After that, reftex will find the bibliography from the master (main.tex) file.


8

The command you need here is reftex-citation, which is bound to C-c [ by default. There is more info in the manual Alternatively, you can use helm-bibtex in place of reftex. Helm-bibtex is more powerful, but it lacks a few features that reftex has, such as allowing you to search your records on different fields.


7

I solved this problem by inserting '(reftex-use-external-file-finders t) into my emacs init file. It makes RefTeX use the appropriate command from reftex-external-file-finders to find the file. In my case that is kpsewhich -format=.bib %f. The default is looking in the folders specified in the environment variables BIBINPUT and TEXINPUT. I prefer this ...


7

Looking to the reftex-ref.el source code I found the following (undocumented) solution: add to your .emacs the line (setq reftex-refstyle "\\Cref") Please note that this will make \Cref the default reference command even when the cleveref isn't actually loaded. If you want to skip the selection of the label type as well, you have to pass the argument " " ...


6

AUCTeX and RefTeX are two separated and independent packages, one can be used without the other. AUCTeX has some facilities about labels and citations management, RefTeX is much better in doing this. Not everyone uses RefTeX and there has been a change in AUCTeX 11.88 to let users choose which labels should be inserted. This selection is independent from ...


5

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 ...


5

This requires AUCTeX: (defun mg-LaTeX-find-bibliography () "Visit bibliography file of the current document." (interactive) (let ((length (length (LaTeX-bibliography-list))) bib) (if (= length 1) (progn (setq bib (car (car (LaTeX-bibliography-list)))) (unless (file-name-extension bib) (setq bib (concat bib ".bib"))) ...


5

RefTeX customization -> RefTeX Label Support -> Reftex Defining Label Environments -> Reftex Label Alist. Change Label prefix string (for every entry). Use %f for filename (extension will be stripped); for details, see the documentation in the customization buffer.


5

Nowadays (RefTex version 24.3), the function is called with three parameters: label, def-fmt, and ref-style. You can safely ignore the new one, so this should work: (defun reftex-format-cref (label def-fmt ref-style) (format "\\cref{%s}" label)) (setq reftex-format-ref-function 'reftex-format-cref) However, there is a better answer provided in this (...


5

This behavior is controlled by the variable reftex-label-alist-builtin in reftex-vars.el, you find an entry there saying: (LaTeX "LaTeX default environments" ;; ... ("equation" ?e "eq:" "~(\\ref{%s})" t (regexp "equations?" "eqs?\\." "eqn\\." "Gleichung\\(en\\)?" "Gl\\.")) You see the parenthesis around \ref. You can change this by ...


4

I've seen people suggest that there's a fault in RefTeX, corrected by inserting (setq reftex-external-file-finders '(("tex" . "/path/to/kpsewhich -format=.tex %f") ("bib" . "/path/to/kpsewhich -format=.bib %f"))) This is not necessary for me.


4

With all due regard to the fact that this is an old post, but the above solutions did not work for me. As this is still quickly found from a Google search, I thought it best to add here. I kept the line (setq reftex-plug-into-AUCTeX t) and I had to modify J Spen's lambda function (also got flyspell to autoload by adding that mode here). (add-hook 'LaTeX-...


4

Create a directory $HOME/texmf/bibtex/bib and put your bib files there. Then you can use just \bibliography{bug.bib}, since both BibTeX and RefTeX search this directory (with the default settings).


4

A possibility is to tell AUCTeX index is a verbatim-like macro. This isn't really true, but verbatim-like macros ignore brace pairing. Add the following code to your init file and restart Emacs: (eval-after-load "latex" '(add-to-list 'LaTeX-verbatim-macros-with-braces "index"))


4

You have to set the variable reftex-cite-format via customize or in your init file. In your init file, this should do the trick: (setq reftex-cite-format '((?\C-m . "~\\cite{%l}") (?t . "\\cite{%l}"))) After pressing C-[, you can enter RET for ~\cite or t for a version without ~.


4

Within AUCTeX, latex.el provides support for vanilla LaTeX. Additions by packages are catered via AUCTeX style files. In this case, this is a shortcoming in cleveref.el which didn't have support for an optional argument in \label macro. This issue is now fixed and will be available with next AUCTeX release. If you want to use it now, customize the ...


3

Since you're using reftex anyways, you can use the reftex function reftex-get-bibfile-list to find all the .bib files associated with your file, and use those as completion targets for find-file: (defun open-current-bib-file () "Visit the bib file for the current document. Only works when reftex is in use, otherwise returns nil." (interactive) (unless ...


3

After a bit of testing, I stand corrected (with respect what I said in the answer you mentioned): what you describe is indeed the default behavior, but of course can be changed. If you want to use amsmath style of referecen, add the following code to your init file: (setq reftex-label-alist '(AMSTeX)) as also suggested in the RefTeX manual. If in ...


3

The basic problem is that the masterfile does not actually make any reference to the supposed sub-file, so it is impossible for any program to know it needs to think about a masterfile-subfile relationship. In AUCTeX' case, parsing kind of works from the subfile because it has a variable informing AUCTeX of the masterfile (but you'll note that AUCTeX/RefTeX ...


3

This is a little bug with RefTeX (AUCTeX without RefTeX works like a charm in this case), but you can workaround it easily: use a comma separated list of bibliography databases: \bibliography{a,b} instead of \bibliography{a.bib} \bibliography{b.bib}


3

The issue here is that AUCTeX does not have a style file for biblatex-chicago. You can roll your own one which simply loads biblatex.el like this: ;;; biblatex-chicago.el --- AUCTeX style for `biblatex-chicago.sty' (TeX-add-style-hook "biblatex-chicago" (lambda () (TeX-run-style-hooks "biblatex")) LaTeX-dialect) ;;; biblatex-chicago.el ends here ...


3

RefTeX comes with a variable called reftex-label-ignored-macros-and-environments. The documentation string says: reftex-label-ignored-macros-and-environments is a variable defined in reftex-vars.el. List of macros and environments to be ignored when searching for labels. The purpose is to ignore environments and macros that use keyval style ...


3

The \label should be placed after the \caption, for it's the latter which generates the number \label refers to (see Why does an environment's label have to appear after the caption?). As a matter of fact, \label will always refer to the previous generated reference number in the document. RefTeX also applies this logic, in searching for the context to ...


3

RefTeX provides a function exactly for this purpose called reftex-create-bibtex-file. From the manual: 4.6 Database Subsets RefTeX offers two ways to create a new BibTeX database file. The first option produces a file which contains only the entries actually referenced in the current document. This can be useful if the database is only ...


2

In order to override possible other eqref macro definitions, you should add a dummy (ignore) to the definition of the macro. This code, in your .emacs, does the trick: (add-hook 'LaTeX-mode-hook '(lambda () (TeX-add-symbols '("eqref" TeX-arg-ref (ignore)))))


Only top voted, non community-wiki answers of a minimum length are eligible