I wanted to raise the _
char in code listings because the T1 font I am using places it too much below the baseline; this causes identifiers like bla_bla
look horrible.
I am using listings
so I thought I could use the literate
option to search/replace _
with a raised version.
Unfortunately, the search/replace option conflicts with the lexer which will break the identifiers when finding _
.
A MWE to illustrate the issue:
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{listings}
\lstset{
columns=[l]flexible,
basicstyle={\sffamily},
morekeywords={to},
}
\begin{document}
\begin{lstlisting}
add_to_list(x)
\end{lstlisting}
\begin{lstlisting}[
literate={
{_}{{\raisebox{.3ex}{\_}}}1
}]
add_to_list(x)
\end{lstlisting}
\end{document}
Is there a way to get this behaviour without disrupting the lexer?
listings
'SelectCharTable
andlst@DefSaveDef
than toliterate
.listings
internals/options but with the fonts themselves are also acceptable.