
次の MWE の場合:
\documentclass{article}
\usepackage{xcolor}
\usepackage{minted}
\begin{document}
\begin{minted}[bgcolor=black,formatcom=\color{white}]{bash}
#! /bin/bash
# script to turn the screen blue
setterm -background blue
echo It is a blue day
\end{minted}
\end{document}
次のようなレンダリングが得られます:
ご覧のとおり、このformatcom
オプションはソース コードの下部に追加の空白行を作成します。
それで、どうやって削除するのでしょうか?
答え1
Mintedは内部でfancyvrbを使用しています。オプションでテキストの色を変更するには、次のようにformatcom
再定義する関数を定義する必要があります。\FancyVerbFormatLine
\newcommand{\shellfgcolor}{%
\def\FancyVerbFormatLine##1{\textcolor{white}{##1}}%
}
formatcom
そして、それをmintedのオプションに渡します。formatcom=\shellfgcolor
したがって、MWE は次のようになります。
\documentclass{article}
\usepackage{xcolor}
\usepackage{minted}
\newcommand{\shellfgcolor}{%
\def\FancyVerbFormatLine##1{\textcolor{white}{##1}}%
}
\begin{document}
\begin{minted}[bgcolor=black,formatcom=\shellfgcolor]{bash}
#! /bin/bash
# script to turn the screen blue
setterm -background blue
echo It is a blue day
\end{minted}
\end{document}