From f3f4e2a6f4876a0db98f247e814333d21cf5fad4 Mon Sep 17 00:00:00 2001 From: Charlotte Van Petegem Date: Tue, 16 Jan 2024 14:51:35 +0100 Subject: [PATCH] Switch back to minted for listings --- .dir-locals.el | 19 ++----------------- book.org | 20 ++++++++++++++++++-- build.el | 18 +----------------- flake.nix | 3 ++- 4 files changed, 23 insertions(+), 37 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 8162a63..6dddadd 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -5,24 +5,9 @@ ("\\section{%s}" . "\\addsec{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}")))) - (org-latex-src-block-backend . listings) - (org-latex-listings-options . (("backgroundcolor" "\\color{white}") - ("commentstyle" "\\color{green}") - ("keywordstyle" "\\color{magenta}") - ("numberstyle" "\\color{gray}") - ("stringstyle" "\\color{purple}") - ("basicstyle" "\\ttfamily") - ("breakatwhitespace" "false") - ("breaklines" "true") - ("captionpos" "b") - ("keepspaces" "true") - ("numbers" "left") - ("numbersep" "5pt") - ("showspaces" "false") - ("showstringspaces" "false") - ("showtabs" "false") - ("tabsize" "2"))) + (org-latex-src-block-backend . minted) (org-latex-prefer-user-labels . t) + (org-latex-pdf-process . ("latexmk -f -pdf -%latex -shell-escape -interaction=nonstopmode -output-directory=%o %f")) (org-html-prefer-user-labels . t) (org-latex-toc-command . "\\frontmatter\n\\addchap{Table of Contents}\n\\label{chap:toc}\n\\listoftoc*{toc}\n\n") (flycheck-languagetool-language . "en-GB") diff --git a/book.org b/book.org index cae66be..1bd6338 100644 --- a/book.org +++ b/book.org @@ -5,7 +5,23 @@ #+LATEX_CLASS_OPTIONS: [paper=240mm:170mm,parskip] #+LATEX_COMPILER: lualatex #+LATEX_HEADER: \usepackage[inline]{enumitem} -#+LATEX_HEADER: \usepackage{listings} +#+LATEX_HEADER: \usepackage{shellesc, luacode} +#+LATEX_HEADER: \begin{luacode*} +#+LATEX_HEADER: function parseargv() +#+LATEX_HEADER: local rep = {} +#+LATEX_HEADER: for k, x in pairs(arg) do +#+LATEX_HEADER: local kw, vw = string.match(x, "([^=]+)=?([^=]*)") +#+LATEX_HEADER: rep[kw] = vw +#+LATEX_HEADER: end +#+LATEX_HEADER: return rep +#+LATEX_HEADER: end +#+LATEX_HEADER: local arguments = parseargv() +#+LATEX_HEADER: local outputdir = arguments["-output-directory"] +#+LATEX_HEADER: if outputdir ~= nil then +#+LATEX_HEADER: tex.print([[\PassOptionsToPackage{outputdir={]]..outputdir..[[}}{minted}]]) +#+LATEX_HEADER: end +#+LATEX_HEADER: \end{luacode*} +#+LATEX_HEADER: \usepackage[newfloat]{minted} #+LATEX_HEADER: \usepackage{color} #+LATEX_HEADER: \usepackage{url} #+LATEX_HEADER: \usepackage[type=report]{ugent2016-title} @@ -1093,7 +1109,7 @@ Another feature that teachers wanted that we had not built into a judge previous The API for the R judge was designed to follow the visual structure of the feedback table as closely as possible, as can be seen in the sample evaluation code in Listing\nbsp{}[[lst:technicalrsample]]. Tabs are represented by different evaluation files. -In addition to the =testEqual= function demonstrated in Listing\nbsp{}[[lst:technicalrsample]] there are some other functions to specifically support the requested functionality. +In addition to the =testEqual= function demonstrated in listing\nbsp{}[[lst:technicalrsample]] there are some other functions to specifically support the requested functionality. =testImage= will set up some the R environment so that generated plots (or other images) are sent to the feedback table (in a base 64 encoded string) instead of the filesystem. It will also by default make the test fail if no image was generated (but does not do any verification of the image contents). An example of what the feedback table looks like when an image is generated can be seen in Figure\nbsp{}[[fig:technicalrplot]]. diff --git a/build.el b/build.el index 7bf793c..26962d0 100644 --- a/build.el +++ b/build.el @@ -14,23 +14,7 @@ ("\\section{%s}" . "\\addsec{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}"))) - org-latex-src-block-backend 'listings - org-latex-listings-options '(("backgroundcolor" "\\color{white}") - ("commentstyle" "\\color{green}") - ("keywordstyle" "\\color{magenta}") - ("numberstyle" "\\color{gray}") - ("stringstyle" "\\color{purple}") - ("basicstyle" "\\ttfamily") - ("breakatwhitespace" "false") - ("breaklines" "true") - ("captionpos" "b") - ("keepspaces" "true") - ("numbers" "left") - ("numbersep" "5pt") - ("showspaces" "false") - ("showstringspaces" "false") - ("showtabs" "false") - ("tabsize" "2")) + org-latex-src-block-backend 'minted org-latex-prefer-user-labels t org-latex-toc-command "\\frontmatter\n\\addchap{Table of Contents}\n\\label{chap:toc}\n\\listoftoc*{toc}\n\n") diff --git a/flake.nix b/flake.nix index dd75f21..3df7fec 100644 --- a/flake.nix +++ b/flake.nix @@ -104,6 +104,7 @@ packages = [ full-texlive pkgs.nixpkgs-fmt + (pkgs.python3.withPackages (ps: [ ps.pygments ])) ]; commands = [ { @@ -139,7 +140,7 @@ builddir=$(mktemp -d --tmpdir=/tmp) fi ${emacs}/bin/emacs -batch -load build.el - ${full-texlive}/bin/latexmk -f -pdf -lualatex -interaction=nonstopmode -output-directory="''${builddir}" book.tex + ${full-texlive}/bin/latexmk -f -pdf -lualatex -shell-escape -interaction=nonstopmode -output-directory="''${builddir}" book.tex mv "''${builddir}"/book.pdf . if ! [ $# -eq 1 ] then