latex-sourcecodepro
latex-sourcecodepro copied to clipboard
Backticks are not displayed when using pdfLaTeX.
When I render some code with the listings environment, the backtick is not displayed:
\begin{lstlisting}
expecting backtick here ->`<-
\end{lstlisting}
The resulting PDF has no backtick in it.

The LaTeX error message I get is:
[WARNING] Missing character: There is no ` in font SourceCodePro-Regular-tlf-ts1!
I included the package without any options:
\usepackage{sourcecodepro}
and modified the listing environment:
\lstdefinestyle{eisvogel_listing_style}{
basicstyle = \color{listing-text-color}\small\ttfamily{}\linespread{1.15},
...
}
\lstset{style=eisvogel_listing_style}
See the original issue here.
Hmm, the backtick doesn't seem to have made it to the Type1 fonts. I will try to take a look at this some time next week. As a work around you could try using XelaTeX (if possible), the package will use the original OpenType font in that case.
Minimal example to reproduce (with pdflatex):
\documentclass{standalone}
\usepackage[default]{sourcecodepro}
\usepackage{textcomp}
\begin{document}
backtick: >\textasciigrave<
\end{document}
Thanks for reporting!
Any news on this?
Seems to be still unresolved.
As a workaround (for pdfLaTeX) the backtick can be set explcitly as \char0 when Type 1 fonts are used.
\documentclass{standalone}
\usepackage{listings}
\usepackage{sourcecodepro}
\lstset{
basicstyle=\ttfamily, % SourceCode Pro
literate={`}{{\char0}}1 % backtick is \char0 in T1, \char18 otherwise
}
\begin{document}
\texttt{backtick in text: \char0{}a\char0{}} |\,\,
\begin{lstlisting}
backtick in listing: `a`
\end{lstlisting}
\end{document}
Yes, the issue is still unresolved. I will take another look at it if/when I have time (may take a while), until then PRs are welcome!
As an alternative workaround, the snippet should work for getting backticks to work in verbatim or lstlisting environments, and for \textasciitilde to work in any other environment.
This seems to work in any order such that \usepackage{upquote} does not come after both of the other two lines (which frustratingly means it can’t just be added to the definition of sourcecodepro, as importing upquote after it will break it). However, if this definition is wrapped in \AtBeginDocument (\AtBeginDocument{\def\textasciigrave{\char0}}), they can be used in any order. This might be a good way to go forward?
\usepackage{sourcecodepro}
\usepackage{upquote}
\def\textasciigrave{\char0}