1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
\documentclass{minimal}
\usepackage{listings}
\lstnewenvironment{code}[1][]{\lstset{#1}}{}
\lstnewenvironment{python_code}{\lstset{language=python}}{}
\begin{document}
\begin{MyMathEnv}
f(x) = 1
\end{MyMathEnv}
\begin{python_code}
def test(argument: str) -> str:
"""
Test function.
"""
return argument
\end{python_code}
\begin{code}[language=rust]
fn main() {
println!("Hello World!");
}
\end{code}
\begin{code}[language=C]
#include<stdio.h>
main() {
int i = 0;
printf("Hello World");
}
\end{code}
\end{document}
|