silkeh / latex-sourcecodepro

Source Code Pro for LaTeX
17 stars 2 forks source link

Backticks are not displayed when using pdfLaTeX. #4

Open Wandmalfarbe opened 6 years ago

Wandmalfarbe commented 6 years ago

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.

silkeh commented 6 years ago

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!

Wandmalfarbe commented 6 years ago

Any news on this?

wamserma commented 5 years ago

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}
silkeh commented 5 years ago

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!

c-harding commented 4 years ago

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}