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"))
  • Did you evaluate that code or restart Emacs? – giordano Apr 28 '15 at 19:24
  • @giordano Yes. I restarted emacs after modifying emacs configuration file but the effect was same as before. – Shahzad Apr 29 '15 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 Apr 29 '15 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 Apr 29 '15 at 9:23
1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.