11

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

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.

4

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

  • Not true -- bw is included by default. – Sophie Alpert Apr 7 '12 at 21:09
  • @BenAlpert: Yes, of course, bw is included; all I said is that the style I thought the OP wanted was not one of the predefined ones. – Gonzalo Medina Apr 8 '12 at 21:21
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.

  • Please extend this answer to explain what is happening and how this would fix the issue. This way other users will have a better chance to understand the issue and solution. – Martin Scharrer Apr 11 '12 at 9:45
  • I can do better... – projetmbc Apr 11 '12 at 9:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.