Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

With RefTeX C-c [ invokes reftex-citation which first asks for a citation format (what citation macro to use, e.g. \cite or \footcite), then it asks for a regex to search the bibliography database and after you input one it shows the search results (in a buffer named *RefTeX Select*) and lets you choose one bibliography item to put in the citation macro. The list which contains the search results can look like the following screenshot:

Screenshot of *RefTeX Select*

Notice that the list includes the key for each item as well as information such as author and title but that the year or date for an item is not displayed. Is is possible to configure RefTeX so that the date is listed for each item in *RefTeX Select*?

The reason I am asking for this is that including dates in the list might make it easier to distinguish between similar entries (which may not be exemplified by the included screenshot).

I am using RefTeX 4.31 in GNU Emacs 23.3.1. On my setup the variable reftex-bib-year-face's value is font-lock-comment-face.

share|improve this question
    
Reftex is supposed to be showing you the year between the title and the page/chapter info (red in your screenshot). What version of emacs/reftex do you have installed? What is the value of the variable reftex-bib-year-face (you can see this by switching to the *scratch* buffer and typing "reftex-bib-year-face" followed by C-j –  Aaron Jan 17 '12 at 8:20
    
@Aaron I have edited my question to include the requested info. –  N.N. Jan 17 '12 at 9:53
    
My bibtex keys all have a year in them, so I've never noticed this… –  Seamus Feb 29 '12 at 15:56
    
@Seamus Yes, it seems to be that RefTeX recognizes the bibtex key date but not year. –  N.N. Feb 29 '12 at 17:05

2 Answers 2

up vote 1 down vote accepted

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 the year and the date. I assume there will only ever be one or the other, so you should see what you want. Add this to your .emacs and see how it works:

(eval-after-load "reftex-cite" 
  '(defun reftex-format-bib-entry (entry)
     ;; Format a BibTeX ENTRY so that it is nice to look at
     (let*
         ((auth-list (reftex-get-bib-names "author" entry))
          (authors (mapconcat 'identity auth-list ", "))

          ;; modified code here:
          (year      (concat (reftex-get-bib-field "year" entry)
                             (reftex-get-bib-field "date" entry)))
          ;; end modified code

          (title     (reftex-get-bib-field "title" entry))
          (type      (reftex-get-bib-field "&type" entry))
          (key       (reftex-get-bib-field "&key"  entry))
          (extra
           (cond
            ((equal type "article")
             (concat (reftex-get-bib-field "journal" entry) " "
                     (reftex-get-bib-field "volume" entry) ", "
                     (reftex-get-bib-field "pages" entry)))
            ((equal type "book")
             (concat "book (" (reftex-get-bib-field "publisher" entry) ")"))
            ((equal type "phdthesis")
             (concat "PhD: " (reftex-get-bib-field "school" entry)))
            ((equal type "mastersthesis")
             (concat "Master: " (reftex-get-bib-field "school" entry)))
            ((equal type "inbook")
             (concat "Chap: " (reftex-get-bib-field "chapter" entry)
                     ", pp. " (reftex-get-bib-field "pages"   entry)))
            ((or (equal type "conference")
                 (equal type "incollection")
                 (equal type "inproceedings"))
             (reftex-get-bib-field "booktitle" entry "in: %s"))
            (t ""))))
       (setq authors (reftex-truncate authors 30 t t))
       (when (reftex-use-fonts)
         (put-text-property 0 (length key)     'face
                            (reftex-verified-face reftex-label-face
                                                  'font-lock-constant-face
                                                  'font-lock-reference-face)
                            key)
         (put-text-property 0 (length authors) 'face reftex-bib-author-face
                            authors)
         (put-text-property 0 (length year)    'face reftex-bib-year-face
                            year)
         (put-text-property 0 (length title)   'face reftex-bib-title-face
                            title)
         (put-text-property 0 (length extra)   'face reftex-bib-extra-face
                            extra))
       (concat key "\n     " authors " " year " " extra "\n     " title "\n\n"))))
share|improve this answer
    
Thanks! This does not work if I place it in my .emacs and restart Emacs but it does work if I visit my .emacs and evaluate it. –  N.N. Jul 25 '12 at 8:03
    
Huh. I'll take a look at when it needs to load this evening. Maybe it should be eval-after-load "auctex". –  Tyler Jul 25 '12 at 11:35
    
It seems eval-after-load "auctex" neither helps. –  N.N. Jul 29 '12 at 14:06
    
The function that gets redefined is in reftex-cite.el, not reftex.el. I changed the call above, it should work now (it does in my tests). –  Tyler Jul 30 '12 at 12:52
    
Thanks! It works for me too now. –  N.N. Jul 30 '12 at 12:54

In my version of RefTeX (which I installed as part of TeX Live 2011), the behavior you'd like to see is enabled automatically. I took a look at some of the RefTeX configuration options, and one thing for you to try might be the reftex-sort-bibtex-matches, which can be done by year. That's the option that's enabled for me by default.

share|improve this answer
    
I am not asking for how to sort entries but how to explicitly list their date. For me reftex-sort-bibtex-matches is set to reverse-year (sort entries by decreasing year) and that is the default value. –  N.N. Jan 16 '12 at 15:16
    
Sorry that didn't work. I understood your question---this was a crack at which customization option might change the display behavior. FWIW, I've received useful feedback at the AucTeX forum on Nabble in re: questions having to do with RefTeX: old.nabble.com/Gnu---AUCTeX---General-f1475.html –  Bernhard Jan 16 '12 at 15:23
    
Appreciated. I tried to set reftex-sort-bibtex-matches to year but that did not help. I think the variable only controls what to sort by and not what to show. –  N.N. Jan 16 '12 at 15:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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