Debian Codegraph @

texmf-dist/doc/latex/moodle/test/test_fancyvrb.tex

raw
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 \newif\iffvextra
13 \fvextratrue % comment this line to use vanilla 'fancyvrb'
14 \iffvextra
15 \usepackage{fvextra,xcolor}
16 \else
17 \usepackage{fancyvrb} % must be loaded after fancybox
18 \fi
19
20 \fvset{firstline=3,firstnumber=2,lastline=7,numbers=left,tabsize=4,numberblanklines=false}
21 \iffvextra
22 \fvset{highlightlines={2-5,8},numbers=both}
23 \fi
24 \begin{document}
25
26 \section*{Introduction}
27
28 This document is intended to check the support of \textsf{fancyvrb} or
29 \textsf{fvextra} packages.
30
31 The only command supported is \texttt{VerbatimInput[<options>]\{<filename>\}}.
32 The variant with a star is unsupported.
33
34 Outside of the moodle question bodies, \texttt{VerbatimOut} environments can be
35 set to define portions of code.
36
37 \begin{quiz}{Fancy Verbatim}
38 % /!\ firstline and lastline set previously would apply to VerbatimOut
39 \begin{VerbatimOut}[firstline,lastline]{test.log}
40 % !TeX encoding = UTF-8
41 % !TeX spellcheck = en_US
42 % !TEX TS-program = xelatex
43
44 \documentclass{article}
45 \usepackage[nostamp]{moodle}
46 \newif\iffvextra
47 \fvextratrue
48 \ifxetex % FOR XELATEX
49 \usepackage{fontspec}
50 \else %% FOR PDFLATEX
51 \usepackage[utf8]{inputenc} % necessary
52 \usepackage[T1]{fontenc} % necessary
53 \fi
54 \end{VerbatimOut}
55 \fvset{gobble=2} % remove two characters at the beginning of each line
56 \fvset{frame=none}% overide default display settings for PDF
57
58 % To avoid collision of line and item numbers in PDF, force `left-right' mode:
59 \RecustomVerbatimCommand{\VerbatimInput}{LVerbatimInput}{}
60 \begin{multi}{LaTeX}
61 Pick up the code decorated with line numbering on both sides.
62 \item[feedback={No. Here, line numbers lie on the left side.}]
63 \VerbatimInput{test.log}
64 \item[feedback={No. Here, line numbers lie on the right side.}]
65 \VerbatimInput[numbers=right,firstnumber=last,numberblanklines=true]{test.log}
66 \item[feedback={yes!}]*
67 \VerbatimInput[numbers=left,firstline=9,firstnumber=4,lastline=23]{test.log}
68 \end{multi}
69
70 \begin{filecontents*}[overwrite]{test.log}
71 #include <stdio.h>
72 int main() {
73 char c='\0', *pc=&c;
74 printf("Hello world!\n");
75 return *pc;
76 }
77 \end{filecontents*}
78 \begin{multi}{C}
79 \VerbatimInput[gobble=0,numbers=left,firstline=1,lastline=6]{test.log}
80
81 \item[feedback={}]* ``\&test"
82 \item[feedback={}] 'toast'
83 \item <$<a>$>
84 \end{multi}
85
86 \end{quiz}
87
88 \end{document}