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
|
% !TeX encoding = UTF-8
% !TeX spellcheck = en_US
% !TEX TS-program = lualatex
\documentclass{article}
\usepackage[nostamp]{moodle}
\ifPDFTeX % FOR LATEX and PDFLATEX
\usepackage[utf8]{inputenc} % necessary
\usepackage[T1]{fontenc} % necessary
\else % assuming XELATEX or LUALATEX
\usepackage{fontspec}
\fi
\newif\iffvextra
\fvextratrue % comment this line to use vanilla 'fancyvrb'
\iffvextra
\usepackage{fvextra,xcolor}
\else
\usepackage{fancyvrb} % must be loaded after fancybox
\fi
\fvset{firstline=3,firstnumber=2,lastline=7,numbers=left,tabsize=4,numberblanklines=false}
\iffvextra
\fvset{highlightlines={2-5,8},numbers=both}
\fi
\begin{document}
\section*{Introduction}
This document is intended to check the support of \textsf{fancyvrb} or
\textsf{fvextra} packages.
The only command supported is \texttt{VerbatimInput[<options>]\{<filename>\}}.
The variant with a star is unsupported.
Outside of the moodle question bodies, \texttt{VerbatimOut} environments can be
set to define portions of code.
\begin{quiz}{Fancy Verbatim}
% /!\ firstline and lastline set previously would apply to VerbatimOut
\begin{VerbatimOut}[firstline,lastline]{test.log}
% !TeX encoding = UTF-8
% !TeX spellcheck = en_US
% !TEX TS-program = xelatex
\documentclass{article}
\usepackage[nostamp]{moodle}
\newif\iffvextra
\fvextratrue
\ifxetex % FOR XELATEX
\usepackage{fontspec}
\else %% FOR PDFLATEX
\usepackage[utf8]{inputenc} % necessary
\usepackage[T1]{fontenc} % necessary
\fi
\end{VerbatimOut}
\fvset{gobble=2} % remove two characters at the beginning of each line
\fvset{frame=none}% overide default display settings for PDF
% To avoid collision of line and item numbers in PDF, force `left-right' mode:
\RecustomVerbatimCommand{\VerbatimInput}{LVerbatimInput}{}
\begin{multi}{Multi}
Pick up the code decorated with line numbering on both sides.
\item[feedback={No. Here, line numbers lie on the left side.}]
\VerbatimInput{test.log}
\item[feedback={No. Here, line numbers lie on the right side.}]
\VerbatimInput[numbers=right,firstnumber=last,numberblanklines=true]{test.log}
\item[feedback={yes!}]*
\VerbatimInput[numbers=left,firstline=9,firstnumber=4,lastline=23]{test.log}
\end{multi}
\end{quiz}
\end{document}
|