Can I \lstset to define both Matlab code and Python code? or will last one override the first one? or does listings know the difference when there is a .m or .py extension and use the correct \lstset?
Asked
Active
Viewed 959 times
1 Answers
2
You can do:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}
\begin{document}
\begin{lstlisting}[language=Python, caption={Some Python code}]
class example(object):
pass
\end{lstlisting}
\begin{lstlisting}[language=Matlab, caption={Some Matlab code}]
function [y1, y2] = funfun(x1, x2)
disp(x1)
end
\end{lstlisting}
\end{document}
Or you can \lstset the language before the listing.
marczellm
- 11,809