Hi developers,

I tried to add basic support for the cleveref [1] package to auctex/reftex and want to contribute my results. Attached are a style file and a patch for reftex. It would be nice, if they could be integrated into auctex/reftex.

As I said, the support is basic; the "range" macros and macros, which allow comma separated arguments, would need some care. Perhaps someone could give me some starting points.

Also, let me express, that auctex+emacs IMHO is the best LaTeX editor. Many thanks for that great tool.

Regards,
Marcel


[1] http://www.ctan.org/pkg/cleveref
;;; cleveref.el --- AUCTeX style file with support for cleveref.sty

;; Copyright (C) 1999 Free Software Foundation, Inc.

;; Author: Marcel <[email protected]>
;; Maintainer: [email protected]

;; This file is part of AUCTeX.

;; AUCTeX is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; AUCTeX is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with AUCTeX; see the file COPYING.  If not, write to the Free
;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
;; 02110-1301, USA.

;;; Code:

(TeX-add-style-hook "cleveref"
   (lambda ()
     
     (TeX-add-symbols

      ;; The macros with label arguments
      '("cref" TeX-arg-label)
      '("Cref" TeX-arg-label)
      '("cref*" TeX-arg-label)
      '("Cref*" TeX-arg-label)
      '("crefrange" TeX-arg-label TeX-arg-label)
      '("Crefrange" TeX-arg-label TeX-arg-label)
      '("crefrange*" TeX-arg-label TeX-arg-label)
      '("Crefrange*" TeX-arg-label TeX-arg-label)
      '("cpageref" TeX-arg-label)
      '("Cpageref" TeX-arg-label)
      '("cpagerefrange" TeX-arg-label TeX-arg-label)
      '("Cpagerefrange" TeX-arg-label TeX-arg-label)
      '("namecref" TeX-arg-label)
      '("nameCref" TeX-arg-label)
      '("namecrefs" TeX-arg-label)
      '("nameCrefs" TeX-arg-label)
      '("lcnamecref" TeX-arg-label)
      '("lcnamecrefs" TeX-arg-label)
      '("labelcref" TeX-arg-label)
      '("labelcpageref" TeX-arg-label)
      '("crefalias" TeX-arg-counter "label's type")

      ;; And the other macros used for customization
      "crefdefaultlabelformat" "crefrangeconjunction"
      "crefrangepreconjunction" "crefrangepostconjunction"
      "crefpairconjunction" "crefmiddleconjunction"
      "creflastconjunction" "crefpairgroupconjunction" 
      "crefmiddlegroupconjunction" "creflastgroupconjunction"
      "crefname" "Crefname" "creflabelformat"
      "crefrangelabelformat" "crefformat" "Crefformat"
      "crefrangeformat" "Crefrangeformat" "crefmultiformat"
      "Crefmultiformat" "crefrangemultiformat"
      "Crefrangemultiformat" "labelcrefformat" 
      "labelcrefrangeformat" "labelcrefmultiformat"
      "labelcrefrangemultiformat")

     ;; Install completion for labels
     (setq TeX-complete-list
	   (append
	    '(("\\\\[cC]\\(ref\\|pageref\\)\\*?{\\([^{}\n\r\\%]*\\)"
	       2 LaTeX-label-list "}")
	      ("\\\\[cC]\\(refrange\\|pagerefrange\\){\\([^{}\n\r\\%,]*\\)" 
	       2 LaTeX-label-list "}{}")
	      ("\\\\\\(name[cC]refs?\\|lcnamecrefs?\\|labelcref\\|labelcpageref\\){\\([^{}\n\r\\%,]*\\)" 
	       2 LaTeX-label-list "}"))
	    TeX-complete-list))

;; Fontification
     (when (and (fboundp 'font-latex-add-keywords)
		(eq TeX-install-font-lock 'font-latex-setup))
       (font-latex-add-keywords '(("cref" "*{")
				  ("Cref" "*{")
				  ("crefrange" "*{{")
				  ("Crefrange" "*{{")
				  ("cpageref" "*{")
				  ("Cpageref" "*{")
				  ("cpagerefrange" "*{{")
				  ("Cpagerefrange" "*{{")
				  ("namecref" "*{")
				  ("nameCref" "*{")
				  ("namecrefs" "*{")
				  ("nameCrefs" "*{")
				  ("lcnamecref" "*{")
				  ("lcnamecrefs" "*{")
				  ("labelcref" "*{")
				  ("labelcpageref" "*{")
				  ("crefalias" "*{{"))
				'reference))))

(defvar LaTeX-cleveref-package-options '("sort" "nosort" "compress"
                                       "sort&compress" "capitalise"
                                       "nameinlink" "noabbrev")
  "Package options for the cleveref package.")

;;; cleveref.el ends here
? reftex-cleveref-support.patch
Index: reftex-base.el
===================================================================
RCS file: /sources/auctex/reftex/lisp/reftex-base.el,v
retrieving revision 1.21
diff -u -r1.21 reftex-base.el
--- reftex-base.el	30 Jan 2010 16:25:51 -0000	1.21
+++ reftex-base.el	27 May 2012 13:50:28 -0000
@@ -111,6 +111,8 @@
  "Make a LaTeX reference." t)
 (autoload 'reftex-varioref-vref "reftex-ref"
   "Make a varioref reference." t)
+(autoload 'reftex-cleveref-cref "reftex-ref"
+  "Make a cleveref reference." t)
 (autoload 'reftex-fancyref-fref "reftex-ref"
   "Make a fancyref \\fref reference." t)
 (autoload 'reftex-fancyref-Fref "reftex-ref"
Index: reftex-vars.el
===================================================================
RCS file: /sources/auctex/reftex/lisp/reftex-vars.el,v
retrieving revision 1.54
diff -u -r1.54 reftex-vars.el
--- reftex-vars.el	12 Sep 2009 17:41:10 -0000	1.54
+++ reftex-vars.el	27 May 2012 13:50:32 -0000
@@ -951,6 +951,9 @@
      (("\\ref" ?\C-m) ("\\pageref" ?p)))
     ("Varioref" "varioref"
      (("\\vref" ?v) ("\\vpageref" ?g) ("\\Vref" ?V) ("\\Ref" ?R)))
+    ("Cleveref" "cleveref"
+     (("\\cref" ?c) ("\\cpageref" ?h) ("\\crefrange" ?n) ("\\Cref" ?C)
+      ("\\Cpageref" ?H) ("\\Crefrange" ?N)))
     ("Fancyref" "fancyref"
      (("\\fref" ?f) ("\\Fref" ?F)))
     ("Hyperref" "hyperref"
_______________________________________________
auctex-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to