12

I just started using the minted package, to produce formatted source codes.

I thought the style bw is a black and white style of pygmentize and it just uses italic and bold to format the code (I tried the code below), but I was wrong. Is there any way to produce formatted code which looks good in black and white?

\documentclass{minimal}
\usepackage{minted}

\begin{document}
  \usemintedstyle{bw}
  \inputminted{bash}{sample.sh}
\end{document}

Thanks

grus
  • 121

3 Answers3

10

The problem isn’t the style – bw is correct and works fine! – but the font. The default monospace font of LaTeX doesn’t support italics and bold.

You need to switch to a different font – e.g. by loading the courier package, or by using XeLaTeX and loading a custom font.

Konrad Rudolph
  • 39,394
  • 22
  • 107
  • 160
5

As far as I could see, there's no predefined style to achieve the desired formatting; a list of predefined styles can be obtained by running

pygmentize -L styles

in a terminal.

You can define your own style, and instructions can be found in the website under Creating Own Styles.

Another option would be to use some of the options for the \inputminted command (or for the minted environment) to quickly get something like you want. A little example:

\documentclass{article}
\usepackage{xcolor}
\usepackage{minted}

\begin{document}

\inputminted[bgcolor=black,formatcom=\color{white}]{console}{sample.sh}

\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}

and the file sample.sh:

#! /bin/bash
# script to turn the screen blue
setterm -background blue
echo It is a blue day

enter image description here

Gonzalo Medina
  • 505,128
1

You can also try to use \renewcommand{\ttdefault}{pcr} in your preambule. I use this solution so as to have bold face when I use the listings package. This solution does not need to use the package courrier.

projetmbc
  • 13,315