5

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}
2

1 Answer 1

5

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

You must log in to answer this question.

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