I would like to use the catchfilebetweentags
package to grab code snippets from a source file and use minted
to highlight them.
Imagine I have the following in program.scala
:
//<a
def someFunctionA = {
// some code
}
//a>
def aFunctionIDontCareAbout = {
// irrelevant stuff
}
//<b
def someFunctionB = {
// important code!
}
//b>
and the following LaTeX document:
\documentclass{article}
\usepackage{minted}
\usepackage{catchfilebetweentags}
\begin{document}
% Nicely formatted snippet:
\begin{minted}{scala}
def someNicelyHighlightedFunction = {
// not from the file
}
\end{minted}
% Expanding, but unformatted snippet:
\CatchFileBetweenDelims{\a}{program.scala}{<a}{//a>}
\a
% Non-expanding snippet inside minted environment:
\CatchFileBetweenDelims{\b}{program.scala}{<b}{//b>}
\begin{minted}{scala}
\b
\end{minted}
\end{document}
Is there any way I can get \b
to expand inside the verbatim
environment used by minted
?
(I am not committed to catchfilebetweentags
or to minted
in particular, but I do need Pygments highlighting on extracted code fragments.)