4

I'm using listings to show some source code (bash scripts) in my document but there is a problem, when using mono spaced fonts, the space between dashes is very small and in the printed document two or more contiguous dashes seems as a continuous line.

The courier font hasn't this problem, but I would like to use Bera Mono or DejaVu Sans Mono.

Is there a way to avoid this situation?

EDIT: This is the code that reproduces the problem, I am using pdflatex.

\documentclass[letterpaper,12pt,twoside]{report}
\usepackage{listings}
\lstnewenvironment{code}
{
    \fontsize{10pt}{1pt}
    \usefont{T1}{fvm}{m}{n}
    \lstset
    {
        showspaces=false,
        showstringspaces=false
    }
} { }

\begin{document}
\begin{code}
    diff --version | head -n1
    find --version | head -n1
    gawk --version | head -n1
\end{code}
\end{document}

Sample output

I like Herbert's solution but I added the code only to clarify how this problem happen.

3
  • Do you change the font, or do you use listings, verbatim or even alltt? As far as I know, none of the latter have this issue.
    – Raphael
    Oct 23, 2013 at 6:13
  • Which TeX format are you using -- pdfLaTeX, XeLaTeX, or LuaLaTeX? If you use the fontspec package, have you enabled the option Ligatures=TeX option for monospaced fonts? Please advise.
    – Mico
    Oct 23, 2013 at 7:10
  • I'm using pdflatex. The problem is when I use listings.
    – rendon
    Oct 23, 2013 at 13:34

1 Answer 1

1

I cannot see it:

\documentclass{article}
%\usepackage{fontspec}%% when running xelatex or lualatex
\usepackage{listings}
%\setmonofont{DejaVu Sans Mono}
\usepackage{dejavu}

\begin{document}
\begin{lstlisting}[basicstyle=\ttfamily]
---
--
-
\end{lstlisting}
\end{document}

enter image description here

1
  • Great! I suppose that my problem is in the form I specify the font.
    – rendon
    Oct 23, 2013 at 13:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .