GNU bug report logs - #19624
RefTeX TOC should not scan words in verbatim environments

Previous Next

Package: auctex;

Reported by: Zengxu Yang <moonlight.yang <at> gmail.com>

Date: Mon, 19 Jan 2015 01:20:02 UTC

Severity: normal

Tags: wontfix

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 19624 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Zengxu Yang <moonlight.yang <at> gmail.com>
Cc: 19624 <at> debbugs.gnu.org
Subject: Re: bug#19624: RefTeX TOC should not scan words in verbatim
 environments
Date: Mon, 04 Mar 2024 14:43:50 +0100
Zengxu Yang <moonlight.yang <at> gmail.com> writes:

> RefTeX TOC scans words in verbatim environments, too. And this makes TOC incorrect. For example,
>
> \documentclass{article}
>
> \begin{document}
> \section{First}
> \label{sec:first}
>
> \section{Second}
> \label{sec:second}
>
> \begin{verbatim}
> \section{Third}
> \end{verbatim}
>
> \section{Last}
> \label{sec:last}
>
> \end{document}
>
> Section "Third" is in a verbatim environment and should not be shown
> in RefTeX TOC. But the RefTeX TOC buffer is shown as:
>
> TABLE-OF-CONTENTS on ~/Documents/test/emacs/reftextest.tex
> SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
> ------------------------------------------------------------------------------
>      1 First
>      2 Second
>      3 Third
>      4 Last
>
> Verified using Emacs 24.4 with AucTeX 11.87 on Debian 8.
>
> The best solution is skipping scanning all predefined and user defined
> verbatim environments in AucTeX(for example, verbatim, Verbatim,
> minted).

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I can confirm what you describe.  But I'm not sure if hacking RefTeX to
ignore the verbatim environments is worth the effort.  You can easily
achieve this by using a package like fancyvrb and use its "gooble" key
for the environment in question where you comment out the \section,
e.g.:

--8<---------------cut here---------------start------------->8---
\documentclass{article}

\usepackage{fancyvrb}

\begin{document}

\section{First}
\label{sec:first}

\section{Second}
\label{sec:second}

\begin{Verbatim}[gobble=2]
% \section{Third}
\end{Verbatim}

\section{Last}
\label{sec:last}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
--8<---------------cut here---------------end--------------->8---

and you get the following RefTeX TOC:

--8<---------------cut here---------------start------------->8---
TABLE-OF-CONTENTS on ~/path/to/file.tex
SPC=view TAB=goto RET=goto+hide [q]uit [r]escan [l]abels [f]ollow [x]r [?]Help
------------------------------------------------------------------------------
     1 First
     2 Second
     3 Last
--8<---------------cut here---------------end--------------->8---

So I think this is a "wontfix", therefore I'm closing this report.

Best, Arash




This bug report was last modified 1 year and 162 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.