auctex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] reftex-label-alist for ctable package


From: Tassilo Horn
Subject: Re: [AUCTeX] reftex-label-alist for ctable package
Date: Thu, 26 Jul 2012 21:25:50 +0200
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.1.50 (gnu/linux)

Michael Bach <address@hidden> writes:

Hi Michael,

> The ctable macro has the following exemplary structure:
>
> \ctable[
>   pos = htbp,
>   cap = shortcap,
>   caption = longcap,
>   label = tab:me,
>   ]{lll}{
>   \tnote{Who is that guy?}
>   }{
> \FL
> Me & Myself & I
> \ML
> how & are & you? \NN
> I\tnote& am & fine
> \LL
> }

Oh, yes, those nasty keyval thingies.  Once I tried to get listings
working and failed just like you.

Could you try the attached patch?  It's against the reftex version in
the current emacs trunk, but those files don't change that often, so
probably it'll apply against the latest release as well.

Ah, and one restriction: You have to write labels like so

  [..., label={tab:foo}, ...]

that is, no spaces around the =, and the {} are mandatory.  That could
probably be relaxed a bit, but maybe you'd get false positives then...

I tried it with the attached tex file and it seems to work for ctable
and listings (which I added, but the context isn't that good).

Bye,
Tassilo

=== modified file 'lisp/textmodes/reftex-vars.el'
--- lisp/textmodes/reftex-vars.el       2012-04-09 13:05:48 +0000
+++ lisp/textmodes/reftex-vars.el       2012-07-26 19:15:59 +0000
@@ -116,13 +116,17 @@
       ("\\footnote[]{}" ?n "fn:" "~\\ref{%s}" 2
        (regexp "footnotes?" "Fussnoten?"))
 
+      ;; ctable package
+      ("\\ctable[]{}{}{}" ?t "tab:" "\\ref{%s}" 1 ("table" "Tabelle"))
+
+      ;; listings package
+      ("lstlisting" ?l "lst:" "~\\ref{%s}" nil (regexp "[Ll]isting"))
+
       ("any"       ?\  " "   "~\\ref{%s}" nil)
 
       ;; The label macro is hard coded, but it *could* be defined like this:
       ;;("\\label{*}" nil nil nil nil)
-      ))
-
-    )
+      )))
   "The default label environment descriptions.
 Lower-case symbols correspond to a style file of the same name in the LaTeX
 distribution.  Mixed-case symbols are convenience aliases.")

=== modified file 'lisp/textmodes/reftex.el'
--- lisp/textmodes/reftex.el    2012-01-19 07:21:25 +0000
+++ lisp/textmodes/reftex.el    2012-07-26 19:12:08 +0000
@@ -1284,7 +1284,7 @@
 ;          (wbol "\\(\\`\\|[\n\r]\\)[ \t]*")
            (wbol "\\(^\\)[ \t]*")  ; Need to keep the empty group because
                                   ;;; because match number are hard coded
-           (label-re "\\\\label{\\([^}]*\\)}")
+           (label-re "\\(?:\\\\\\label\\|label=\\){\\([^}]*\\)}")
            (include-re (concat wbol
                                "\\\\\\("
                                (mapconcat 'identity

\documentclass{article}

\begin{document}

\section{bla}
\label{sec:bla}

foo bar baz

\subsection{blub}
\label{sec:blub}

Ding

\ctable[ pos = htbp, cap = shortcap, caption = longcap, label={tab:me}]{lll}{
  \tnote{Who is that guy?}
  }{
\FL
Me & Myself & I
\ML
how & are & you? \NN
I\tnote& am & fine
\LL
}

\begin{lstlisting}[label={lst:foo}]
  foo abb
\end{lstlisting}

\section{goo}
\label{sec:goo}
dum di dum

\end{document}

reply via email to

[Prev in Thread] Current Thread [Next in Thread]