# Tag Info

23

There are two ways to make RefTeX find your bibliography. I suggest to use both approaches for robustness. To make RefTeX recognize your bibliography you can add it to the list reftex-default-bibliography. To do this add the following to your .emacs: ;; So that RefTeX finds my bibliography (setq reftex-default-bibliography '("path/to/bibfile.bib")) and ...

13

The variable you need to hook into is reftex-cite-format. Somewhere in my Emacs init file, I have this code: (eval-after-load 'reftex-vars '(progn ;; (also some other reftex-related customizations) (setq reftex-cite-format '((?\C-m . "\\cite[]{%l}") (?f . "\\footcite[][]{%l}") (?t . "\\textcite[]{%l}") ...

6

Another way to integrate biblatex and csquotes with RefTeX is via YASnippet. You make a snippet for every citation macro you want to use and have the snippets call reftex-citation. I use a setup where I type "ct" and press Tab and then I get to choose between the two following snippets. For \auctocite: # -*- mode: snippet -*- # name: autocite \autocite # ...

6

The following (untested!) code should give you the behavior you are looking for. You need to put it in your Emacs initialization file (.emacs or some such, depending on your platform). (defun reftex-format-cref (label def-fmt) (format "\\cref{%s}" label)) (setq reftex-format-ref-function 'reftex-format-cref) (The trivial code for the defun was modified ...

6

I like how you asked "how is it possible to..." instead of "is it possible to...". Because of course it is possible, reftex being awesome and OCD-friendly. :) reftex-renumber-simple-labels is an interactive autoloaded Lisp function. Renumber all simple labels in the document to make them sequentially. So... M-x reftex-renumber-simple-labels RET ...

6

The correct place to fix this is the regular expressions that RefTeX uses to parse the BibTeX file. However, in the version of RefTeX (4.31) that I am looking at it seems that [{(] shows up every place you would expect. EDIT: After poking at it a bit, it seems the issue is that in reftex.el ( and ) are defined as punctuation is the reftex-syntax-table and ...

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

5

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

5

Unless you include the relevant parts of your .emacs it's hard to help you. Here's what I got in my .emacs which seems to do what you're after (and I'm also using TeX Live 2011): ; Turn on RefTeX for AUCTeX, http://www.gnu.org/s/auctex/manual/reftex/reftex_5.html (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; Make RefTeX interact with AUCTeX, ...

4

You can make the argument optional on the flip side of the command: \makeatletter \def\includeas#1{ \@ifnextchar[{\includeas@opt{#1}}{\includeas@{#1}} } \def\includeas@#1{ \include{#1} } \def\includeas@opt#1[#2]{ \foo{#2} \include{#1} } \makeatother Then you will call it as: Without optional \includeas{filename.tex} With optional ...

4

Since you seem to already be using YASnippet it might be better to implement this via YASnippet instead of via AUCTeX. Here is an example of such a snippet: # -*- mode: snippet -*- # name: cleveref \cref # key: rf # -- \cref{${1:label$(unless yas/modified-p (reftex-reference nil 'dont-insert))}}$0 Using this you write "rf" and when you expand it ... 4 A \ref to the same \label will not give different results. Your \jobname.log file should contain a warning, there were multiply defined labels. The only option is to change the \label. For large documents you just need to come up with a convention that makes sense to you, and would be fairly simple for others to understand. For example, if your ... 4 Electric super and subscripts uses texmathp to determine when they should be run. This function is controlled by the texmathp-tex-commands variable which you can customize. You will need to call texmathp-compile if you set it outside of the customize interface. Adding the following to your custom-set-variables and restarting Emacs should do the trick. ... 4 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"))) ... 3 I'm moving my comment here as it gives me more space: But then again, there are quite a lot of Emacs + reftex users reading this site as well. C-c [, runs reftex-citation, you you could just define your own short cut. Here is what I would do ; unset C-z, to be used to make my own C-z prefix (global-unset-key [(control z)]) (global-set-key [(control z) (c)] ... 3 I've figured out the solution, and I'm posting it here for completeness. RefTeX in conjunction with AucTeX can be made aware of labels in all of the documents that make up a multi-document structure of the sort I'm using. One just has to include pointers to the master file in each of the files making up the structure, in this example, main.tex, part1.tex, ... 3 To get RefTeX to work with csquotes I use this in my .emacs: (eval-after-load "tex" '(TeX-add-style-hook "csquotes" (lambda () (TeX-add-symbols '("textcquote" [ "pre-note (post-note if alone)" ] [ "post-note" ] TeX-arg-cite [ "Punctuation" ] t ignore ignore) '("blockcquote" [ "pre-note (post-note if alone)" ] [ "post-note" ] TeX-arg-cite ... 2 You have to use TeX-command to call the command. It should look something like: (add-hook 'LaTeX-mode-hook (lambda () (local-set-key "\C-c\C-v" (lambda () (interactive) (TeX-save-document (TeX-master-file)) (TeX-command "Doall" 'TeX-master-file' -1))))) ... 2 ; Turn on RefTeX for AUCTeX, http://www.gnu.org/s/auctex/manual/reftex/reftex_5.html (add-hook 'LaTeX-mode-hook 'turn-on-reftex) ; Make RefTeX interact with AUCTeX, http://www.gnu.org/s/auctex/manual/reftex/AUCTeX_002dRefTeX-Interface.html (setq reftex-plug-into-AUCTeX t) I had the above already in my latex file but changed from just having: (require ... 2 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 ... 2 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 ... 1 Yasnippet can get slightly buggy when you start embedding lisp code. I suggest you report this bug. Meanwhile, here's how you can try to fix it. \cite{${1:label(unless yas/modified-p (reftex-citation nil 'dont-insert))}}\$0 Backticks are an alternative way to embed lisp in yasnippet, and they can work better (if the code you're embedding doesn't use ...

1

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}

1

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

1

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

1

Just discovered how to resolve this. Part of the problem was that the tex document comprised one master file and other source files which were being included from the master. All I had to do was add the following %%% Local Variables: %%% mode: latex %%% TeX-master: "NAME_OF_MASTER_FILE" %%% End: at the bottom of each file except the master. Then reftex ...

1

Reftex does not display the date field in the citation list, by design, only the year field. There is no option to tweak to correct this. You can fix this by modifying the responsible code directly, however. It's a rather long function, and it only requires a very small change. I've modified the 'year' value that is displayed, so that it will contain both ...

1

In the *RefTeX Select* buffer you can type C-h m to see all the keybindings in effect for the mode. From reading the keys available there doesn't appear to be a way. In fact, I don't even see a way to skip to the next heading of the same level. That seems quite useful, and probably not hard. I'll put it on my list of things to do someday. Hiding may be ...

1

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.

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