Hi,

the following MWE compiles like a charm from a LaTeX point of view but
has a syntax highlighting problem from an AUCTeX point of view: because
the character just after the 1st `\begin{lstlisting}' is not what is
expected (not a `['):

1. what follows until the 1st `\end{lstlisting}' is not considered as
   a listing (not on a yellow background),
2. this 1st `\end{lstlisting}' and what follows is considered as
   a listing (on a yellow background) until the next `\begin{lstlisting}',
3. etc.

Hence, after the 1st `\begin{lstlisting}', listing and not listing
regions are inverted.

Is there a way to circumvent this trouble?

Thanks in anticipation.

--8<---------------cut here---------------start------------->8---
\documentclass{beamer}
\usepackage{lmodern}
\usepackage{fancyvrb}
\usepackage{listings}

\lstset{%
  escapechar=+,%
  basicstyle=\ttfamily,%
  language=[LaTeX]TeX%
}%

\newenvironment{latexcode}
{%
  \VerbatimOut{tmp.tex}%
}{%
  \endVerbatimOut%
  \lstinputlisting{tmp.tex}%
}

\begin{document}
\begin{frame}[fragile]
\begin{latexcode}
\begin{lstlisting}+\only<2->{+[+\emph{options}+]+}+
+\emph{listing}+
\end{lstlisting}
\end{latexcode}
\end{frame}

\begin{frame}[fragile]
\begin{latexcode}
\begin{lstlisting}
+Foo bar+
\end{lstlisting}
\end{latexcode}
\end{frame}
\end{document}
--8<---------------cut here---------------end--------------->8---

-- 
Denis

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

Reply via email to