TransWikia.com

How can I get Latex to use the fonts that are already on my PC via Xetex?

TeX - LaTeX Asked by flesh on April 24, 2021

I am an absolute beginner with LaTeX. I have Texnic Centre and MikTeX 2.8. I just want to be able to use the truetype or opentype fonts from my C:/Windows/Fonts folder. How hard can it be? Apparently, very.

I have found a page that says I can use XeTeX, but I have absolutely no idea how to use XeTeX. I think it’s installed – it came with MikTeX, but I don’t know how to get it working. I’d really appreciate some “baby steps” on how I can get this working.

Thanks

Edit

I have tried konrad’s suggestion below and got a fontsec.cfg error. However, using the following:

usepackage{xltxtra}
setmainfont[Mapping=tex-text]{Tahoma}

I got it to work. I don’t know why the first failed and this one worked, but it does appear to be using system fonts.

One Answer

A minimal document that uses an OTF font from your PC can look like this:

documentclass{article}

usepackage{fontspec}
setmainfont{Constantia}

begin{document}
This is a text.
end{document}

Assuming that you have the font “Constantia” installed (included in current versions of Windows and Microsoft Office). You can of course use any other font.

To build the document, all you need to do is change the build command from latex (or pdflatex) to xelatex.

I don’t know how to do this in TeXnicCenter but it should be very straightforward – consult the help file.

Finally, have a look at the documentation of fontspec. This is the package that controls loading of TTF and OTF fonts.

There is one rather important caveat: XeTeX assumes that your document is saved using the character encoding UTF-8. This controls how extended characters (á, ö, ß …) are represented in the file. Unfortunately, TeXnicCenter still has no support for UTF-8, which is a crying shame. However, as long as you only use the normal American alphabet, there should be no problems. If you need extended characters, you must unfortunately switch to a better editor.

Answered by Konrad Rudolph on April 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP