diff --git a/janishutz-helpers.tex b/janishutz-helpers.tex index ce02df0..2414119 100644 --- a/janishutz-helpers.tex +++ b/janishutz-helpers.tex @@ -692,6 +692,55 @@ \DeclareMathOperator\arcsinh{arcsinh} +% ┌ ┐ +% │ Minted │ +% └ ┘ +\usepackage{minted} +\usepackage{fancyvrb} + +% Args: Code. +% Alternative: Use \mint{}|code| +\newcommand{\inlinecode}[1]{\shade{gray}{\texttt{#1}}} + +% Args: Language, Code +\newenvironment{code}[1]{ + \VerbatimEnvironment + \begin{minted}[ + autogobble, + breaklines, + breakindentnchars=2, + frame=lines, + framesep=2mm, + mathescape, + baselinestretch=1.1, + linenos + ]{#1}} +{\end{minted}} + +% Args: Language, file relative to root file +\newcommand{\inputcode}[2]{ + \inputminted[ + autogobble, + breaklines, + breakindentnchars=2, + frame=lines, + framesep=2mm, + mathescape, + baselinestretch=1.1, + linenos + ]{#1}{#2} +} + +% Args: Language, Base directory (with trailing slash), file (no slash at start) +\newcommand{\inputcodewithfilename}[3]{ + \begin{figure}[h!] + \texttt{File: \detokenize{#3}} + \rmvspace + \inputcode{#1}{#2#3} + \end{figure} +} + + % ┌ ┐ % │ Index │ % └ ┘ diff --git a/src/core/minted.sty b/src/core/minted.sty new file mode 100644 index 0000000..8c85cce --- /dev/null +++ b/src/core/minted.sty @@ -0,0 +1,47 @@ +% ┌ ┐ +% │ Minted │ +% └ ┘ +\RequirePackage{minted} +\RequirePackage{fancyvrb} + +% Args: Code. +% Alternative: Use \mint{}|code| +\newcommand{\inlinecode}[1]{\shade{gray}{\texttt{#1}}} + +% Args: Language, Code +\newenvironment{code}[1]{ + \VerbatimEnvironment + \begin{minted}[ + autogobble, + breaklines, + breakindentnchars=2, + frame=lines, + framesep=2mm, + mathescape, + baselinestretch=1.1, + linenos + ]{#1}} +{\end{minted}} + +% Args: Language, file relative to root file +\newcommand{\inputcode}[2]{ + \inputminted[ + autogobble, + breaklines, + breakindentnchars=2, + frame=lines, + framesep=2mm, + mathescape, + baselinestretch=1.1, + linenos + ]{#1}{#2} +} + +% Args: Language, Base directory (with trailing slash), file (no slash at start) +\newcommand{\inputcodewithfilename}[3]{ + \begin{figure}[h!] + \texttt{File: \detokenize{#3}} + \rmvspace + \inputcode{#1}{#2#3} + \end{figure} +}