1

I'm trying to do something like this:

\begin{lstlisting}[language=Python, caption=Here is an equation $y=2x$.]
def y(x):
  return 2*x
\end{lstlisting}

But I get an error due to the equation in the caption. Is there a way to do it?

  • 7
    Try to put the caption inside brackets, caption={...} – StefanH Sep 23 at 17:54
  • Worked, thanks! – sean Sep 24 at 9:34

Your Answer

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

Browse other questions tagged or ask your own question.