Closed Witiko closed 10 months ago
Try this patch
\begin{filecontents}[overwrite, nosearch, noheader]{python-01.py}
# python
def f(x):
return x**2
\end{filecontents}
\begin{filecontents}[overwrite, nosearch, noheader]{ruby.rb}
# ruby
def func
puts "message"
end
\end{filecontents}
\documentclass{article}
\usepackage[draft=false, langlinenos]{minted}
\usepackage{xpatch}
\makeatletter
\ifminted@draft
\xpatchcmd\inputminted
{\VerbatimInput{#3}}
{\minted@langlinenoson
\VerbatimInput{#3}%
\minted@langlinenosoff}
{}{\PatchFailed}
\else
\xpatchcmd\inputminted
{\minted@pygmentize[#3]{#2}}
{\minted@langlinenoson
\minted@pygmentize[#3]{#2}%
\minted@langlinenosoff}
{}{\PatchFailed}
\fi
\makeatother
\setminted{linenos, firstnumber=last, autogobble}
\setminted[python]{numbersep=30pt}
\begin{document}
\begin{minted}{python}
# python
def f(x):
return x**2
\end{minted}
\begin{minted}{ruby}
# ruby
def func
puts "message"
end
\end{minted}
\inputminted{python}{python-01.py}
\inputminted{ruby}{ruby.rb}
\begin{minted}{python}
# python
def f(x):
return x**2
\end{minted}
\begin{minted}{ruby}
# ruby
def func
puts "message"
end
\end{minted}
\end{document}
draft=false |
draft=true |
---|---|
![]() |
![]() |
The development version on GitHub now has a new package option inputlanglinenos
that extends the existing langlinenos
to cover \inputminted
as well. A new release including this package option will be on CTAN soon.
Unline the
minted
environment and the\mint
commands, the\inputminted
command does not seem to be affected by thelanglinenos
option:The documentation does not explicitly mention that the
\inputminted
should be affected by thelanglinenos
option, so this is not necessarily a bug. However, the inconsistency is surprising.