3

I would like to manually set a small section of my text to either Verdana or Cambria (with font sizes ranging from 11, 12, 18 or 20) but have no idea how to do that.

I've tried

\usepackage[T1]{fontenc}
\usepackage{lxfonts}

To get Verdana loaded but it just went ahead and rewrote all my text in Verdana.

  • 1
    Could you consider to switch to Xe- or LuaLaTeX? – TeXnician Sep 28 '18 at 14:04
  • Are those different TeX editors? I'm using TeXmaker with TeXlive at the moment. – Chung Ren Khoo Sep 28 '18 at 14:39
  • 2
    You mention wanting to use font sizes between 11 and 20 points. What's the main font size of your document? 11pt? 12pt? Something else? – Mico Sep 28 '18 at 14:41
  • It's currently at 12pt but I would like certain Verdana and Cambria texts to be at 11, 12, 18 and 20. – Chung Ren Khoo Sep 28 '18 at 14:42
  • 2
    @ChungRenKhoo - No, XeLaTeX and LuaLaTeX are not editors (à la TeXmaker). They are different programs. The default LaTeX program in your installation of TeXmaker is probably pdfLaTeX. You should consult the user guide of the TeXmaker program to figure out how to switch over from pdfLaTeX to LuaLaTeX (or XeLaTeX). – Mico Sep 28 '18 at 14:43
  • How is LuaLaTeX better than pdfLaTeX for this? – Chung Ren Khoo Sep 28 '18 at 14:44
  • 1
    @ChungRenKhoo - To change the font size, just use the usual \fontsize directive. E.g., \fontsize{11}{13}\selectfont. (Here, 11pt is the main font size and 13pt is the so-called baselineskip.) – Mico Sep 28 '18 at 14:49
  • 1
    @ChungRenKhoo - pdfLaTeX doesn't let you specify system fonts such as Verdana and Cambria. In contrast, LuaLaTeX (in conjunction with the fontspec package) does let you use system fonts. – Mico Sep 28 '18 at 14:50

1 Answers1

4

If you are free to use LuaLaTeX or XeLaTeX, and if fonts named Verdana and Cambria are installed on your computer system, all you need to do is load the fontspec package, issue a suitable \setmainfont directive, and issue two \newfontfamily directives to specify how to make the text font switch over to Cambria and Verdana, respectively. Use grouping to delimit the scope of the \Cambria and \Verdana directives.

Aside: In both \newfontfamily directives, I'd use the option Scale=MatchLowercase to ensure that the fonts mesh reasonably well (at least size-wise) with the main text font. And, if you need the basic "TeX ligatures" such as en- and em-dashes, be sure to specify the option Ligatures=TeX.

enter image description here

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times New Roman} % or some other suitable font

\newfontfamily\Cambria{Cambria}[Scale=MatchLowercase,
                                Ligatures=TeX]
\newfontfamily\Verdana{Verdana}[Scale=MatchLowercase,
                                Ligatures=TeX]
\newcommand\qbf{The quick brown fox jumps over the lazy dog}
\begin{document}
\qbf. --- Times New Roman 

{\Cambria \qbf. --- Cambria}

{\Verdana \qbf. --- Verdana}
\end{document} 
Mico
  • 506,678
  • Is there a way to use these fonts with pdfLaTex? I know it doesn't support fonts well but I don't want to switch engines just because of the font either. – Jack Nov 03 '19 at 08:05
  • @jackz314 - Switching engines might take 2 to 4 minutes of clean-up work in our document (e.g., no longer loading the fontenc package and loading the fontspec package instead), whereas adapting an OpenType font to a Type1 setup that can be handled by pdfLaTeX is a job that can rather time-consuming, to put it charitably, even for people who have done this before. Have you given LuaLaTeX a try? Five years ago, its output could be different from that of pdfLaTeX; nowadays, that should no longer be the case. – Mico Nov 03 '19 at 08:22
  • I'm pretty new to LaTex, so I haven't really tried any of the stuff. I remember reading somewhere that pdfLaTex has a slightly better micro typography system than the other engines, so I just don't want to sacrifice that (even though I haven't tried changing it yet) if possible since changing font is not a top priority for me. Also it'd be interesting to learn how changing the font works in pdfLaTex even if it's time consuming, after all, more options won't hurt. – Jack Nov 03 '19 at 08:59
  • @jackz314 - You wrote, "I remember reading somewhere that pdfLaTex has a slightly better micro typography system than the other engines". This statement was true once upon a time, a dozen years ago or more, when XeLaTeX and LuaLaTeX were still new on the scene. It's not true anymore. Anyway, I can see no valid reason for reinventing the wheel, in the guise of creating an entirely new font setup when the existing setup performs just fine. If you really want to continue to explore this subject, you ought to pose a new query to this site. – Mico Nov 03 '19 at 09:52
  • Got it. I will switch to XeLaTex then since it's not at a disadvantage for my use case. Thanks for explaining everything to me. – Jack Nov 03 '19 at 09:58
  • @jackz314 - If one of your objectives is to fully exploit a font's micro-typographic features, you should load the microtype package and use LuaLaTeX. (For a number of reasons, microtype's support for XeLaTeX isn't quite as good.) Incidentally, the very first time one uses a new font under LuaLaTeX, one may experience a significant delay, in the tens of seconds; this delay is due to a utility program (called luaotflaod) needing to create a font-specific cache file. But that's just a one-time issue; from the second compilation run onward, that delay should no longer occur. – Mico Nov 03 '19 at 10:15
  • That's good to know, thank you! I still have a lot to learn about Tex stuff. – Jack Nov 03 '19 at 10:25