From b53ed29e96d3c9bbf0e5d8487c0d1b5ad6185a39 Mon Sep 17 00:00:00 2001 From: teridax Date: Tue, 5 Sep 2023 13:42:55 +0200 Subject: [PATCH] added example for minted --- minted/main.tex | 81 ++++++++++++++++++++++++++++++++++++++++++++ minted/some_code.txt | 8 +++++ 2 files changed, 89 insertions(+) create mode 100644 minted/main.tex create mode 100644 minted/some_code.txt diff --git a/minted/main.tex b/minted/main.tex new file mode 100644 index 0000000..77323cd --- /dev/null +++ b/minted/main.tex @@ -0,0 +1,81 @@ +\documentclass{article} + +% =================================================== +% _____ _ +% | ____|_ ____ _ _ __ ___ _ __ | | ___ +% | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \ +% | |___ > < (_| | | | | | | |_) | | __/ +% |_____/_/\_\__,_|_| |_| |_| .__/|_|\___| +% |_| +% =================================================== + +% License: MIT +% Author: Sven Vogel +% Copyright: Sven Vogel (2023) + +% Based on the tutorial at: +% https://www.overleaf.com/learn/latex/Code_Highlighting_with_minted + +% =================================================== +% include the required package +% make sure this is installed: +% > tlmgr install minted +\usepackage{minted} +% =================================================== + +\title{Minted-Syntax-Hightlightning-Test} +\author{Sven Vogel} +\date{September 2023} +\begin{document} +\maketitle + +% =================================================== +% Add the list of listings +\renewcommand\listoflistingscaption{List of source codes} +\listoflistings % Now typeset the list +% =================================================== + +\section{Introduction} +The following will show some syntax highlighted source code: + +% =================================================== +% define some source code and specifiy the language +% every minted block is wrapped in a listing block for alignment and +% the option to add some caption and label +\begin{listing}[ht] + % vvvvvvvv <= specifiy language + \begin{minted}{python} +def incmatrix(genl1,genl2): + for i in range(m-1): + for j in range(i+1, m): + [r,c] = np.where(M2 == M1[i,j]) + for k in range(len(r)): + VT[(i)*n + r[k]] = 1; + VT[(i)*n + c[k]] = 1; + VT[(j)*n + r[k]] = 1; + VT[(j)*n + c[k]] = 1; + + if M is None: + M = np.copy(VT) + else: + M = np.concatenate((M, VT), 1) + + VT = np.zeros((n*m,1), int) + return M + \end{minted} + \caption{Some python code} % add a caption + \label{listing:1} % add a label for referencing +\end{listing} + +This code is imported from a file: + +% import code from a file: +\begin{listing}[ht] + \inputminted{latex}{some_code.txt} + \caption{Some latex code} + \label{listing:2} +\end{listing} + +% =================================================== + +\end{document} diff --git a/minted/some_code.txt b/minted/some_code.txt new file mode 100644 index 0000000..21c6808 --- /dev/null +++ b/minted/some_code.txt @@ -0,0 +1,8 @@ +\documentclass{article} +\usepackage{minted} +\title{Importing files using minted} +\begin{document} +The next code will be directly imported from a file: + +\inputminted{octave}{BitXorMatrix.m} +\end{document} \ No newline at end of file