2

I'm not able to get a mono-spaced font working when I use the fontspec package on my OSX install of TeX Live 2016. I'm able to specify and render other fonts such as Adobe Garamond Pro and Helvetica Neue, but when I try to use Courier New for my monofont, the font that renders is not Courier or even a fixed width font; I'm pretty sure it's Computer Modern or a similar variable-width font.

Note that I get the following warning when I compile this; when I remove the fontspec package and \setmainfont calls, my \texttt text shows up properly as a fixed-width font. However, the other fonts are not as I wish (Garamond, Helvetica), so I'm trying to get this working using fontspec. I also tried \usepackage{courier} with fontspec but the problem persisted. I also tried using other fixed-width fonts, such as Inconsolata in my \setmonofont call; there were no warnings (it found the font) but it still rendered Computer Modern. When I remove the \setmonofont completely, it still does the same thing.

I found a number of SO posts related to missing fonts, but nothing with this particular issue, nor my apparent interaction with fontspec. I frankly don't even know what EU1/pcr/m/it is, and am not sure how to debug this problem. I'd appreciate any debugging tips, as well as the solution to this problem.

LaTeX Font Warning: Font shape `EU1/pcr/m/it' undefined
(Font)              using `EU1/pcr/m/n' instead on input line 85.

Here's the document:

\documentclass[12pt]{article}

\linespread{1.25}

% TODO: this is causing monofonts to break
\usepackage{fontspec}

\setromanfont{Adobe Garamond Pro}
\setsansfont{Helvetica Neue}
\setmonofont{Courier New}

%\usepackage{courier} % also tried this and it also doesn't work

\begin{document}

\textit{italics here}
\textbf{bold here}
\texttt{monospaced here code\_goes\_here}
{\ttfamily This text is using the \textbf{Andale} \textit{Mono} font}

\end{document}

Details about my latex build:

pdfTeX 3.14159265-2.6-1.40.17 (TeX Live 2016)
kpathsea version 6.2.2
Copyright 2016 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.21; using libpng 1.6.21
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.04
  • you run pdftex but not xelatex or lualatex! – user2478 Jun 1 '17 at 4:59
  • I can't reproduce the issue with the same setup (just used Times New Roman instead of Adobe Garamond Pro). – egreg Jun 1 '17 at 6:20
  • On the other hand, you should try and update fontspec (together with the rest of TeX Live). – egreg Jun 1 '17 at 7:06
  • Don't use the courier package with xelatex. It is not meant for it. \setmonofont{Courier New} works fine on my OS, but to see which font is used in your case we will need access to the pdf. – Ulrike Fischer Jun 1 '17 at 8:18
  • Here's the command I run to generate this file: xelatex -no-pdf --shell-escape main.tex && xelatex -no-pdf --shell-escape main.tex && xelatex --shell-escape main.tex ; Hubert, the output above showing pdfTeX is from running xelatex -v – Kulluk007 Jun 1 '17 at 11:30
1

this works fine with xelatex or lualatex:

\documentclass[12pt]{article}
\usepackage{fontspec}

\setromanfont{Adobe Garamond Pro}
\setsansfont{Helvetica Neue}
\setmonofont{DejaVu Sans Mono}[Scale=MatchLowercase,FakeStretch=0.9]

\begin{document}

\textit{italics here}
\textbf{bold here}
\texttt{monospaced here code\_goes\_here}
{\ttfamily This text is using the \textbf{Andale} \textit{Mono} font}

\end{document}

enter image description here

  • I realized I had \setmonofont[Mapping=tex-text]{Courier New} (note the Mapping argument) in here based on an example I had found on SO. When I took that out, everything worked fine. Thank you. – Kulluk007 Jun 1 '17 at 12:08
  • DejaVu looks nicer than Courier – user2478 Jun 1 '17 at 12:25
  • Yeah, I agree. I actually ended up going with InputMono, which is the font I use in my editor. – Kulluk007 Jun 1 '17 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.