latex-sourcecodepro icon indicating copy to clipboard operation
latex-sourcecodepro copied to clipboard

Backticks are not displayed when using pdfLaTeX.

Open Wandmalfarbe opened this issue 8 years ago • 5 comments

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. screenshot 2017-11-16 16 24 04

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.

Wandmalfarbe avatar Nov 16 '17 15:11 Wandmalfarbe

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!

silkeh avatar Nov 19 '17 18:11 silkeh

Any news on this?

Wandmalfarbe avatar Aug 22 '18 21:08 Wandmalfarbe

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}

wamserma avatar Dec 12 '18 12:12 wamserma

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!

silkeh avatar Dec 13 '18 10:12 silkeh

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}

c-harding avatar May 10 '20 21:05 c-harding