3

I have a problem when trying to show a console output in my document with the package lstlisting. It shows a spare single quotes, as seen in the first line of the below picture:

enter image description here

This code reproduces the problem (at least for me). I'd like help to get rid of them.

\documentclass{article}
\usepackage{listings}
\usepackage{xcolor}
\lstdefinestyle{mystyle}{
        backgroundcolor=\color{white},
        basicstyle={\footnotesize\color{black},\fontfamily{cmtt}\selectfont,\bfseries},
        stringstyle=\color{black},
        breakatwhitespace=false,
        breaklines=true,
        captionpos=b,
        keepspaces=true,
        showspaces=false,
        showstringspaces=false,
        showtabs=false,
        tabsize=2,
}
\lstset{style=mystyle}
\begin{document}
\lstset{escapeinside={<@}{@>}}
\begin{lstlisting}
traceroute to upm.es (138.100.200.6), 30 hops max, 60 byte packets
1  192.168.1.1 (192.168.1.1) <@\textcolor{red}{[*]}@>  1.600 ms  3.262 ms  3.260 ms
2  10.233.128.1 (10.233.128.1) <@\textcolor{red}{[*]}@>  8.496 ms  13.889 ms  13.911 ms
3  10.239.240.113 (10.239.240.113) <@\textcolor{red}{[*]}@>  13.945 ms  14.828 ms  17.957 ms
4  10.254.14.1 (10.254.14.1) <@\textcolor{red}{[*]}@>  27.655 ms  28.202 ms  29.326 ms
5  10.239.240.181 (10.239.240.181) <@\textcolor{red}{[*]}@>  32.501 ms 10.254.13.201 (10.254.13.201) <@\textcolor{red}{[*]}@>  33.297 ms  33.321 ms
6  10.254.13.237 (10.254.13.237) <@\textcolor{red}{[*]}@>  29.209 ms 10.254.2.137 (10.254.2.137) <@\textcolor{red}{[*]}@>  19.383 ms 10.254.2.145 (10.254.2.145) <@\textcolor{red}{[*]}@>  17.886 ms
7  10.254.3.226 (10.254.3.226) <@\textcolor{red}{[*]}@>  20.164 ms  17.590 ms 10.254.14.106 (10.254.14.106) <@\textcolor{red}{[*]}@>  54.655 ms
8  rediris.baja.espanix.net (193.149.1.26) <@\textcolor{green}{[AS6895]}@>  22.132 ms  22.362 ms rediris.alta.espanix.net (193.149.1.154) <@\textcolor{green}{[AS6895]}@>  22.240 ms
9  redimadrid-cieamt-router.rediris.es (130.206.212.106) <@\textcolor{blue}{[AS766]}@>  18.079 ms  21.496 ms *
10  * upm-ciemat.net.redimadrid.es (193.145.14.133) <@\textcolor{blue}{[AS766]}@>  55.954 ms *
11  www.upm.es (138.100.200.6) <@\textcolor{blue}{[AS766]}@>  20.736 ms  20.866 ms  19.413 ms\end{lstlisting}
\end{document}
4

They're commas, actually. The culprit is

basicstyle={\footnotesize\color{black},\fontfamily{cmtt}\selectfont,\bfseries},

which should be

basicstyle=\ttfamily\footnotesize,

You have to combine all font declaration, not give a list of declarations.

Note that \bfseries will do nothing with family cmtt that has no boldface. Also \color{black} seems redundant.

  • Yep, that did the trick, nice and easy. Thank you for the additional explanation. – mrbolichi May 12 '17 at 21:59

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.