11

I don't know which LaTeX packages I recently updated caused this issue, but I suddenly noticed today that my single quotes in \texttt{} and verbatim environments were not scaled correctly. I'm using xelatex with \setmonofont[Scale=0.7]{Source Code Pro}. Here is what single quotes look like before (in \texttt{}):

old

And here is what they look like now:

new

They are not scaled correctly in verbatim environments, either:

same

Here is my minimal example:

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmonofont[Scale=0.7]{Source Code Pro}

\usepackage{upquote}
\usepackage{textcomp}

\begin{document}

\texttt{'hello world'}

\texttt{\textquotesingle{}hello world\textquotesingle{}}

\begin{verbatim}
x = 'hello world'
\end{verbatim}

\end{document}

Output (with xelatex and the latest versions of all packages tlmgr update --self --all, and Source Code Pro downloaded from Google fonts):

So literal single quotes are scaled correctly in \texttt{} (first line), but \textquotesingle{} and single quotes in verbatim are problematic.

If I don't use the upquote package, the issue with single quotes in verbatim will be fixed (but I hope I can keep upquote):

Now I have run out of ideas, and I don't know if this issue was caused by a certain recent update of a certain package, or changes in the Source Code Pro font on Google fonts. I hope \textquotesingle{} and single quotes in verbatim can be displayed correctly (if possible, with the upquote package).

2
  • From the description of upquote on CTAN: >The pack­age switches the type­writer font to Com­puter Modern Typewriter in OT1 en­cod­ing, and mod­i­fies the be­haviour of ver­ba­tim, ver­ba­tim*, \verb, and \verb* to print in the “` and ' way”.< Your problem is that for any non-cm-font textcomp (an obsolete package) is loaded which also does not match your font.
    – TeXnician
    Commented Feb 16, 2017 at 6:33
  • 2
    They're not just a different size but a different glyph (look at the tops). This isn't surprising given the package clash others have reported
    – Chris H
    Commented Feb 16, 2017 at 8:55

2 Answers 2

10

The problem is that the new TU-encoding now used by fontspec is missing suitable definitions for \textquotesingle and \textasciigrave (which were previously present in xunicode) and so the default definitions from textcomp kicks in. If I add definitions everything is fine.

Edit

The missing definitions have been added to the LaTeX-code. So after the next update of LaTeX is should work correctly out-of-the-box.

Edit 2

The code in my example works fine as only typewriter fonts are used. With a roman font it is more complicated as the "TeX-ligatures" interferes. Some discussion is going on.

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmonofont[Scale=0.7]{Source Code Pro}
\DeclareTextSymbol{\textquotesingle}     \UnicodeEncodingName{"0027}
\DeclareTextSymbol{\textasciigrave}     \UnicodeEncodingName{"0060}


\usepackage{upquote}
\usepackage{textcomp}

\begin{document}

\texttt{'hello world'}

\texttt{\textquotesingle{}hello world\textquotesingle{}}

\begin{verbatim}
x = 'hello world'
\end{verbatim}

\end{document}

enter image description here

8
  • Thanks! I found the tilde also need to be fixed: \DeclareTextSymbol{\textasciitilde} \UnicodeEncodingName{"007E}. BTW, carets become problematic as well but it seems to be a different issue, so I posted a new question: tex.stackexchange.com/q/354258/9128
    – Yihui Xie
    Commented Feb 16, 2017 at 20:39
  • I updated the latex package today, and unfortunately it is broken now no matter if I add the definitions you mentioned or not. The log file: pastebin.com/yLZfzCEq
    – Yihui Xie
    Commented Feb 22, 2017 at 22:37
  • there is a bug in tuenc. Try if this helps: tex.stackexchange.com/a/355239/2388 Commented Feb 22, 2017 at 22:53
  • No, same error after I tried the solution there.
    – Yihui Xie
    Commented Feb 23, 2017 at 4:17
  • Your latex is not up-to-date. LaTeX2e <2016/03/31>. See also the fontspec warning: "tu-clash" in your log. If you really updated latex then you didn't regenerate the formats correctly. (I have LaTeX2e <2017/01/01> patch level 2). Commented Feb 23, 2017 at 8:59
3

From the description of upquote on CTAN:

The pack­age switches the type­writer font to Com­puter Modern Typewriter in OT1 en­cod­ing, and mod­i­fies the be­haviour of ver­ba­tim, ver­ba­tim*, \verb, and \verb* to print in the “` and ' way”.

Your problem is that for any non-cm-font textcomp (an obsolete package) is loaded which also does not match your font. So you cannot use textcomp and because it depends on it, you cannot use upquote either.

7
  • Thanks! Any idea which package should I use if I need \textquotesingle? Or I just \renewcommand it to a single quote? It is not that I want to use it, but the background of my question is that I was converting Markdown to LaTeX through Pandoc, which converts single quotes to \textquotesingle{}.
    – Yihui Xie
    Commented Feb 16, 2017 at 6:46
  • 1
    @Yihui - The solution should be: (a) don't load the upquote and textcomp packages and (b) issue the instruction \providecommand\textquotesingle{'} to keep Pandoc happy.
    – Mico
    Commented Feb 16, 2017 at 6:48
  • @Mico Perfect. Problem solved by \renewcommand{\textquotesingle}{'}. I cannot use \providecommand since there is not a way to disable the use of upquote in Pandoc's template: github.com/jgm/pandoc-templates/blob/master/default.latex Thanks a lot! I'm still puzzled why it was not a problem before (the last time I compiled my document was about a month ago, and I didn't see any changes in upquote recently).
    – Yihui Xie
    Commented Feb 16, 2017 at 6:59
  • 1
    @Yihui - There have recently been some updates to the fontspec package. I can only speculate that one of the changes was about the ways OT1-encoded glyphs are handled.
    – Mico
    Commented Feb 16, 2017 at 7:16
  • 2
    The description on CTAN is wrong, upquote doesn't change the typewriter font, see the documentation and the code. textcomp is not "obsolete". While it normally shouldn't be needed when using fontspec it doesn't do harm to load it. Commented Feb 16, 2017 at 8:42

You must log in to answer this question.

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