Last active
August 14, 2023 17:33
-
-
Save tuelwer/dfb2717606457558cf33e8dab5d24e4d to your computer and use it in GitHub Desktop.
LaTeX minted Python example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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