-
Notifications
You must be signed in to change notification settings - Fork 2
/
minted.tex
82 lines (59 loc) · 1.7 KB
/
minted.tex
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
\documentclass[onecolumn]{article}
\usepackage{fontspec}
\usepackage{minted}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{fancyvrb}
\usepackage{listings}
%
% Define the URL and text to display on code links:
%
\newcommand{\codeurl}{https://raw.githubusercontent.com/m3g/jlcode_example/master}
\newcommand{\codelinktext}{[Click here to download the code]}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For JuliaMono and Unicode support
\newfontfamily \JuliaMono {JuliaMono-Light.ttf}[ Path = ./, Extension = .ttf ]
\newfontface \JuliaMonoLight{JuliaMono-Light}
\setmonofont{JuliaMonoLight}[ Contextuals=Alternate ]
% Simplify minted usage
\newenvironment{code}
{%
\VerbatimEnvironment
\begin{listing}[H]
\begin{minted}[%
label = code example,% Might want to change or remove this label
linenos,%
breaklines,%
style = paraiso,%
fontsize=\small,%
frame = single%
]{julia}%
}
{%
\end{minted}%
\end{listing}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\subsection*{Code typed inside {\tt code} environment:}
\begin{code}
struct MyType
a :: Int64
end
function f(x :: MyType)
x.a + 1
end
\end{code}
\end{document}
\documentclass[10pt,a4paper]{article}
And \inline{@time f(x) = x + 1} is an example of inline code.
\subsection*{Including code with {\tt codefile}:}
\codefile{./code.jl}
\subsection*{Including code with {\tt codelink}:}
\codelink{./code.jl}
\noindent\\
If {\tt linkonly} is used, only the link is shown: \linkonly{./code.jl}
\begin{figure}[htbp]
\caption{And the link \linkonly{./code.jl} works inside captions.}
\end{figure}
\end{document}