minted
minted copied to clipboard
Autogobble with file input with line ranges
How is autogobble supposed to work with file input? Is it supposed to do nothing, detect the indent from the entire file, or detect it from the given range? I'd assume it's one of the first two, because the last one is not how it in fact behaves. Any workaround besides preprocessing files manually?
autogobble
should dedent the part of the inputted file that is displayed, whether that is the whole file or only a range. This works for me. Can you provide an example?
test.tex
\documentclass{report}
% Code blocks
\usepackage{minted}
\usepackage{color}
\setminted{%
autogobble=true,
codetagify=true,
linenos=true,
breaklines=true,
baselinestretch=0.72,
% https://www.giss.nasa.gov/tools/latex/ltx-178.html
fontsize=\footnotesize
}
\begin{document}
Test \ref{test}.
\section{Test}\label{test}
\inputminted[firstline=2, lastline=4]{cs}{test.txt}
\end{document}
test.txt
(windows line endings, spaces for indentation)
{
{
Hello
World
}
}
Compile with (Windows, MikTeX):
latexmk --shell-escape -pdf test.tex
Result:
Importing the whole file, for reference:
There was a bug that affected output when a line after lastline
had less indentation than the selected range. It should be fixed in the last commit. Until there is a new release of minted
on CTAN, you can download the minted.sty
from the last commit and either put that in the same directory as your document, or replace your existing minted.sty
.
Thanks, awesome