| 1 |
% !TeX encoding = UTF-8 |
| 2 |
% !TeX spellcheck = en_US |
| 3 |
% !TEX TS-program = lualatex |
| 4 |
\documentclass{article} |
| 5 |
\usepackage[nostamp]{moodle} |
| 6 |
\ifPDFTeX % FOR LATEX and PDFLATEX |
| 7 |
\usepackage[utf8]{inputenc} % necessary |
| 8 |
\usepackage[T1]{fontenc} % necessary |
| 9 |
\else % assuming XELATEX or LUALATEX |
| 10 |
\usepackage{fontspec} |
| 11 |
\fi |
| 12 |
\usepackage{minted} |
| 13 |
\usemintedstyle{tango} |
| 14 |
%\RecustomVerbatimEnvironment{Verbatim}{LVerbatim}{} |
| 15 |
\begin{document} |
| 16 |
|
| 17 |
\section*{Introduction} |
| 18 |
|
| 19 |
This document is intended to check the support of the \textsf{minted} package. |
| 20 |
|
| 21 |
The only command supported is |
| 22 |
\texttt{inputminted[<options>]\{<lang>\}\{<filename>\}}. |
| 23 |
|
| 24 |
\begin{quiz}{Minted} |
| 25 |
|
| 26 |
\setminted{numbersep=3ex,tabsize=4,numberblanklines=false,autogobble=true} |
| 27 |
|
| 28 |
\begin{VerbatimOut}{_minted-test_minted/test.tex} |
| 29 |
% !TeX encoding = UTF-8 |
| 30 |
% !TeX spellcheck = en_US |
| 31 |
% !TEX TS-program = xelatex |
| 32 |
|
| 33 |
\documentclass{article} |
| 34 |
\usepackage[nostamp]{moodle} |
| 35 |
\newif\iffvextra |
| 36 |
\fvextratrue |
| 37 |
\ifxetex % FOR XELATEX |
| 38 |
\usepackage{fontspec} |
| 39 |
\else %% FOR PDFLATEX |
| 40 |
\usepackage[utf8]{inputenc} % necessary |
| 41 |
\usepackage[T1]{fontenc} % necessary |
| 42 |
\fi |
| 43 |
\end{VerbatimOut} |
| 44 |
\setminted[latex]{firstline=3,firstnumber=2,lastline=9,numbers=both,style=xcode} |
| 45 |
|
| 46 |
\begin{VerbatimOut}{_minted-test_minted/test.py} |
| 47 |
n = int(input('Type a number, and its factorial will be printed: ')) |
| 48 |
|
| 49 |
if n < 0: |
| 50 |
raise ValueError('non negative integer expected') |
| 51 |
|
| 52 |
fact = 1 |
| 53 |
|
| 54 |
for i in range(2, n + 1): |
| 55 |
fact *= i |
| 56 |
|
| 57 |
print(fact) |
| 58 |
\end{VerbatimOut} |
| 59 |
\setminted[python]{firstline=3,firstnumber=2,lastline=9,numbers=both,style=xcode} |
| 60 |
|
| 61 |
\begin{VerbatimOut}{_minted-test_minted/test.c} |
| 62 |
long some_function(); |
| 63 |
/* int */ other_function(); |
| 64 |
|
| 65 |
/* int */ calling_function() |
| 66 |
{ |
| 67 |
long test1; |
| 68 |
register /* int */ test2; |
| 69 |
|
| 70 |
test1 = some_function(); |
| 71 |
if (test1 > 0) |
| 72 |
test2 = 0; |
| 73 |
else |
| 74 |
test2 = other_function(); |
| 75 |
return test2; |
| 76 |
} |
| 77 |
\end{VerbatimOut} |
| 78 |
\setminted[c]{style=tango,numberblanklines=true,highlightlines={2,4,7}} |
| 79 |
|
| 80 |
\begin{VerbatimOut}{_minted-test_minted/test.pl} |
| 81 |
#!/usr/bin/XXXX |
| 82 |
use strict; |
| 83 |
use warnings; |
| 84 |
use IO::Handle; |
| 85 |
|
| 86 |
my ( $remaining, $tot ); |
| 87 |
|
| 88 |
$remaining = $tot = shift(@ARGV); |
| 89 |
|
| 90 |
STDOUT->autoflush(1); |
| 91 |
|
| 92 |
while ( $remaining ) { |
| 93 |
printf ( "Remaining %s/%s \r", $remaining--, $tot ); |
| 94 |
sleep 1; |
| 95 |
} |
| 96 |
|
| 97 |
print "\n"; |
| 98 |
\end{VerbatimOut} |
| 99 |
\setminted[perl]{firstline=1,firstnumber=1,lastline=19,numbers=left} |
| 100 |
|
| 101 |
\begin{numerical}[tolerance=0]{LaTeX Classes} |
| 102 |
In the following \LaTeX\ code excerpt, on which line is the class loaded? |
| 103 |
\inputminted{latex}{_minted-test_minted/test.tex} |
| 104 |
\item[feedback={yes! |
| 105 |
\inputminted[highlightlines={3}]{latex}{_minted-test_minted/test.tex}},fraction=100] |
| 106 |
4 |
| 107 |
\item[feedback={No. On line 3, there is only a comment.},fraction=0] 3 |
| 108 |
\item[feedback={No. On line 5, the package \texttt{moodle} is |
| 109 |
loaded.},fraction=0] 5 |
| 110 |
\end{numerical} |
| 111 |
|
| 112 |
% To avoid collision of line and item numbers in PDF, force `left-right' mode: |
| 113 |
\RecustomVerbatimEnvironment{Verbatim}{LVerbatim}{frame=lines, |
| 114 |
label={[Beginning of code]End of code},framesep=3mm,numbersep=9pt}% |
| 115 |
\begin{multi}{Languages} |
| 116 |
Select the code written in the Python language. |
| 117 |
\item[feedback={Indeed, this is Python code.}]* |
| 118 |
\inputminted[highlightlines={2,4-5},numbers=both]{python}{_minted-test_minted/test.py} |
| 119 |
\item[feedback={No. This is Perl code.}] |
| 120 |
\inputminted[highlightlines={2,4-5},numbers=right,style=colorful]{perl}{_minted-test_minted/test.pl} |
| 121 |
\item[feedback={No. This is C code.}] |
| 122 |
\inputminted[numbers=left]{c}{_minted-test_minted/test.c} |
| 123 |
\end{multi} |
| 124 |
|
| 125 |
|
| 126 |
\end{quiz} |
| 127 |
|
| 128 |
\end{document} |