Skip to content

Instantly share code, notes, and snippets.

@tuelwer
Last active August 14, 2023 17:33
Show Gist options
  • Save tuelwer/dfb2717606457558cf33e8dab5d24e4d to your computer and use it in GitHub Desktop.
Save tuelwer/dfb2717606457558cf33e8dab5d24e4d to your computer and use it in GitHub Desktop.
LaTeX minted Python example
\documentclass{article}
\usepackage{algorithm}
\usepackage{minted}
\begin{document}
\begin{algorithm}
\vspace{0.2em}
\begin{minted}[xleftmargin=1em, numbersep=6pt, linenos, breaklines]{python}
def fib(n):
"""This function calculates the n-th Fibonacci number."""
if n == 0: # base case
return 0
elif n == 1:
return 1
else:
return fib(n-1) + fib(n-2) # recursive call
\end{minted}
\vspace{-0.5em}
\caption{Fibonacci}
\end{algorithm}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment