1

This question already has an answer here:

I wanna include a bash script in a black box in a pdf using latex. I achieved everything I want, except bold commands in the script using the following code:

\documentclass[11pt,a4paper,DIV=15]{scrartcl} \usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc} 
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{float}
\usepackage{xcolor}
\usepackage[colorlinks,linkcolor=blue]{hyperref}
\usepackage{listings}

\lstset{language=bash,backgroundcolor=\color{lightgray},frame=lrbt,basicstyle=\ttfamily}


\begin{document}


\begin{lstlisting}
#!/bin/bash

pdflatex  $1
echo Anstatt  dieses  Skriptes  haettest  Du  pdflatex
echo auch  einfach  direkt  aufrufen  koennen  ...
\end{lstlisting}

\end{document}

I dont get why listing automatically writes my comments italic, but doesnt recognize echo as an command. As commands should be written bold when using language=bash.

marked as duplicate by Tiuri, Romain Picot, Stefan Pinnow, Phelype Oleinik, Mensch Dec 12 '18 at 12:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Dec 12 '18 at 9:13

This question came from our site for professional and enthusiast programmers.

1

Simply add \usepackage{lmodern}and get bold "echo". It will be a little bit hard to discover because of the background in lightgray.

1

IF you remove basicstyle=\ttfamily then you should be set, it looks like setting typewriter style for strings is removing the bold formatting for key words.

Removing that gives me this. enter image description here