I have some LaTeX inside an org-mode file that is wrapping a Ruby code snippet and providing nice color formatting, which looks kind of like this:
#+LATEX_HEADER: \usepackage[dvipsnames]{xcolor}
#+LATEX_HEADER: \usepackage{listings}
#+LATEX_HEADER: \lstloadlanguages{Ruby}
#+LATEX_HEADER: \lstset{%
#+LATEX_HEADER: basicstyle=\ttfamily\color{black},
#+LATEX_HEADER: commentstyle = \ttfamily\color{red},
#+LATEX_HEADER: keywordstyle=\ttfamily\color{blue},
#+LATEX_HEADER: stringstyle=\color{orange}}
\begin{lstlisting}[language=Ruby]
pairs_list.each {|pair|
if (pair[0]-pair[1]).magnitude < min_dist
min_dist = (pair[0]-pair[1]).magnitude
best_pair = pair
end
}
\end{lstlisting}
All of this works fine except for the square brackets in the array addressing, which are erroneously identified as org footnotes. I tried setting autofn:nil
in options, tried adding #+STARTUP: nofninline, noautofn
and refreshing, but nothing worked. org-mode tries to export the nonexistent footnotes and makes a bunch of garbage.
What's the easiest way to turn this off on a per-file basis?
edit: The reason why you would bother doing this instead of #+BEGIN_SRC #+END_SRC is because that format is uglier and does not include colors (although that may hint at a way to solve it).
\[ \]
doesn't work because the code environment prints backslashes.