ミントパッケージでは、formatcomオプションは下部マージンを設定します

ミントパッケージでは、formatcomオプションは下部マージンを設定します

次の 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 オプションを使用したコンソールレンダリング

ご覧のとおり、この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}

レンダリングするとここに画像の説明を入力してください

関連情報