TransWikia.com

How to put equation within listing caption?

TeX - LaTeX Asked on October 3, 2020

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?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP