1

Using the following code in emacs configuration file makes the listed environment as verbatim.

(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting"))

How can I add following environment to this list.

\lstnewenvironment{code}[2][]{%
 \lstset{#1}%
 \mdframed[style=lstlisting,title={#2}]%
}{\endmdframed}

I have tried the following but its not working

(setq LaTeX-verbatim-environments-local '("Verbatim" "lstlisting" "code"))
4
  • Did you evaluate that code or restart Emacs?
    – giordano
    Commented Apr 28, 2015 at 19:24
  • @giordano Yes. I restarted emacs after modifying emacs configuration file but the effect was same as before.
    – Shahzad
    Commented Apr 29, 2015 at 1:35
  • @giordano The intention is to make the code environment as verbatim so that I can use symbols like _ in my code environment. But when I specify the argument to code environment, emacs doesn't recognize this environment as verbatim any more. For e.g. \begin{code}{hi} some_code \end{code}
    – Shahzad
    Commented Apr 29, 2015 at 8:02
  • @giordano Specifically when I specify a command in that argument. For exmple. \begin{code}{\texttt{S\char`_h} some_code \end{code}
    – Shahzad
    Commented Apr 29, 2015 at 9:23

1 Answer 1

2

For emacs -Q, @giordano's suggestion of restarting emacs should have worked, though all I had to do was evaluate

(add-to-list 'LaTeX-verbatim-environments "code")

and run M-x LaTeX-mode again.

3
  • If file parsing is enabled this isn't even needed ;-)
    – giordano
    Commented Mar 7, 2017 at 18:56
  • If this is true, then I have some impossible bug reports for the mailing list :-) Commented Mar 7, 2017 at 18:58
  • Well, yes, it should. If this isn't the case for you, please report the bug :-)
    – giordano
    Commented Mar 7, 2017 at 20:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .