Reftex and listings

View: New views
5 Messages — Rating Filter:   Alert me  

Reftex and listings

by Damien Cassou-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I would like to use the listings package and be able to reference the
listings through reftex. It seems that it's not so easy to configure.
Can somebody help me please?

Thank you

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Lambdas are relegated to relative obscurity until Java makes them
popular by not having them." James Iry


_______________________________________________
auctex mailing list
auctex@...
http://lists.gnu.org/mailman/listinfo/auctex

Re: Reftex and listings

by Damien Cassou-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

To be more concrete, in the following document, I can't get RefTeX
find a proper reference to put after the word 'Please see Listing'.
The list of references proposes by reftex-references `C-c )' is empty
(even if I rescan and select 'any').

\documentclass{article}
\usepackage{listings}
\begin{document}

\begin{lstlisting}[language=Java, caption={Caption}, label={lst:test}]
test
\end{lstlisting}

Please see Listing

\end{document}



On Fri, Jul 31, 2009 at 4:23 PM, Damien Cassou<damien.cassou@...> wrote:

> Hi,
>
> I would like to use the listings package and be able to reference the
> listings through reftex. It seems that it's not so easy to configure.
> Can somebody help me please?
>
> Thank you
>
> --
> Damien Cassou
> http://damiencassou.seasidehosting.st
>
> "Lambdas are relegated to relative obscurity until Java makes them
> popular by not having them." James Iry
>



--
Damien Cassou
http://damiencassou.seasidehosting.st

"Lambdas are relegated to relative obscurity until Java makes them
popular by not having them." James Iry


_______________________________________________
auctex mailing list
auctex@...
http://lists.gnu.org/mailman/listinfo/auctex

Re: Re: Reftex and listings

by Ralf Angeli-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

* Damien Cassou (2009-07-31) writes:

> To be more concrete, in the following document, I can't get RefTeX
> find a proper reference to put after the word 'Please see Listing'.
> The list of references proposes by reftex-references `C-c )' is empty
> (even if I rescan and select 'any').
>
> \documentclass{article}
> \usepackage{listings}
> \begin{document}
>
> \begin{lstlisting}[language=Java, caption={Caption}, label={lst:test}]
> test
> \end{lstlisting}
>
> Please see Listing
>
> \end{document}

AFAICS only constructs like

\begin{foo}
  \label{<label>}
  ...
\end{foo}

,

\bar{... \label{<label>}}

or

\baz{<label>}{...}

are supported.  That means it has to be the argument of a macro (and
\label is hard-coded).

--
Ralf


_______________________________________________
auctex mailing list
auctex@...
http://lists.gnu.org/mailman/listinfo/auctex

Re: Re: Reftex and listings

by Damien Cassou-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Aug 2, 2009 at 7:58 PM, Ralf Angeli<angeli@...> wrote:

> * Damien Cassou (2009-07-31) writes:
>
>> To be more concrete, in the following document, I can't get RefTeX
>> find a proper reference to put after the word 'Please see Listing'.
>> The list of references proposes by reftex-references `C-c )' is empty
>> (even if I rescan and select 'any').
>>
>> \documentclass{article}
>> \usepackage{listings}
>> \begin{document}
>>
>> \begin{lstlisting}[language=Java, caption={Caption}, label={lst:test}]
>> test
>> \end{lstlisting}
>>
>> Please see Listing
>>
>> \end{document}
>
> AFAICS only constructs like
>
> \begin{foo}
>  \label{<label>}
>  ...
> \end{foo}
>
> ,
>
> \bar{... \label{<label>}}
>
> or
>
> \baz{<label>}{...}
>
> are supported.  That mea

Do you know of any way to do that with the listings package? I saw
some mails in this mailing list about defining a new lstenvironment
but am not sure this works out of the box.

--
Damien Cassou
http://damiencassou.seasidehosting.st

"Lambdas are relegated to relative obscurity until Java makes them
popular by not having them." James Iry


_______________________________________________
auctex mailing list
auctex@...
http://lists.gnu.org/mailman/listinfo/auctex

Re: Reftex and listings

by Martin Görg-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, 02 Aug 2009 20:56:47 +0200, Damien Cassou wrote:

> On Sun, Aug 2, 2009 at 7:58 PM, Ralf Angeli<angeli@...> wrote:
>> * Damien Cassou (2009-07-31) writes:
>>
>>> To be more concrete, in the following document, I can't get RefTeX
>>> find a proper reference to put after the word 'Please see Listing'.
>>> The list of references proposes by reftex-references `C-c )' is empty
>>> (even if I rescan and select 'any').
>>>
>>> \documentclass{article}
>>> \usepackage{listings}
>>> \begin{document}
>>>
>>> \begin{lstlisting}[language=Java, caption={Caption}, label={lst:test}]
>>> test
>>> \end{lstlisting}
>>>
>>> Please see Listing
>>>
>>> \end{document}
>>
>> AFAICS only constructs like
>>
>> \begin{foo}
>>  \label{<label>}
>>  ...
>> \end{foo}
>>
>> ,
>>
>> \bar{... \label{<label>}}
>>
>> or
>>
>> \baz{<label>}{...}
>>
>> are supported.  That mea
>
> Do you know of any way to do that with the listings package? I saw some
> mails in this mailing list about defining a new lstenvironment but am
> not sure this works out of the box.

On Sat, 12 Sep 2009 19:44:17 +0200, Ralf Angeli wrote:

> * Joost Kremers (2009-09-10) writes:
>
>> Is there a way to get RefTeX to recognize these things as labels? I've
>> tried adding a definition to reftex-label-alist and specifying `\ex<*>'
>> for the ENV-OR-MACRO entry, but that doesn't work...
>
> Yes, angle brackets are not supported as delimiters.  I currently don't
> have a workaround for that.
>
>> PS: there is a discrepancy between the doc string for
>> reftex-label-alist and the info section "Non-Standard Environments".
>> The former says that if ENV-OR-MACRO is a function, it must return a
>> cons cell (FUNCTION . POSITION), the latter says that it must return
>> just a buffer position.
>
> Thanks for the hint.  I fixed this in CVS.
>
> By the way, the lines produced by your MUA are rather long.

I just posted this method under the Thread (RefTeX: defining new label
environment). Here it is again:
Enable display of labels in comments using reftex-label-menu-flags. Then
just put a comment with the same label name somewhere near your actual
label (the one reftex can't find).

I just did it for lstlistings like this:
%\label{lst:mylisting}
\begin{lstlisting}[caption={Some caption},label=lst:mylisting]
Some code
\end{lstlisting}

And as additional info specially for lstlisting, I also added a new
environment using the reftex-label-alist customization buffer. Please
search on the net for an explanation of how to do that. It is not that
hard.

Cheers,
Martin

--
For emails use cs dot tu-berlin dot de as the domain (behind the at).



_______________________________________________
auctex mailing list
auctex@...
http://lists.gnu.org/mailman/listinfo/auctex