Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When generating an index of all my Listings, the library seems to use the wrong dashes to connect words:

Expected

Unported-2.0-Graphic

Actual

Unported—2.0—Graphic

In the title of the listings, I used the normal dash -, so it has to be somewhere in the library that the double dashes -- are created.

As this is not really a big issue, but totally wrong typography, I'd very much like to change it to the correct way.

MWE

\documentclass[11pt,oneside,a4paper]{scrartcl}
\usepackage{listings}
\lstset{caption=\lstname}
\begin{document}
\lstlistoflistings
\begin{lstlisting}[name=Unported-2.0-Graphic]
\end{lstlisting}
\end{document}
share|improve this question
    
Please add a minimal working example (MWE) that illustrates your problem. –  Joseph Wright Sep 6 '11 at 7:57
    
Done. Sorry for forgetting –  Florian Peschka Sep 6 '11 at 12:59

1 Answer 1

up vote 5 down vote accepted

The listings package defines an internal command for replacements within filenames. One of these replacements replaces - with \textendash. You can redefine this command to make the hyphens actual hyphens:

\documentclass[11pt,oneside,a4paper]{scrartcl}
\usepackage[]{listings}
\makeatletter
\def\lst@filenamerpl{_\textunderscore $\textdollar}
\makeatother
\lstset{caption=\lstname}
\begin{document}
\lstlistoflistings
\begin{lstlisting}[name=Unported-2.0-Graphic]
\end{lstlisting}
\end{document}

output of code

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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