I want to put arbitrary portions of my text into a font that looks like it came out of a 1960s manual typewriter. In particular, each character must occupy a column, identical in width to all other columns. By "arbitrary" I mean a portion that could contain paragraph breaks, not just single paragraphs as with \texttt{something}.

This leads to several questions.

  1. What is the default font used by xelatex for \textttt{something}?
  2. How can I use that same font for subsets of my text that include paragraph breaks?
  3. In the code below, \texttt{iiiiiii} and \texttt{mmmmmmm} give identical widths as desired. But the default, supposed "monospace font" of these letters gives emphatically different widths. Why in the world is the default "monospace font" in xetex not monospace?
  4. Why does the code below throw the following warning?
LaTeX Font Warning: Font shape `TU/monofont/m/n' undefined
(Font)              using `TU/lmr/m/n' instead on input line 15.

[1] (./b.aux)

LaTeX Font Warning: Some font shapes were not available, defaults substituted.

Here is my MWE:

\setmainfont{Times New Roman}
hello world


This is a separate multi-paragraph block ...

iiiiiii : 7 characters
mmmmmmm : 7 characters

... inside curly brackets. I want it to 
look like it came out of
a 1960s manual typewriter.}

Now this should be back in main font.

My TeX installation is as follows:

This is XeTeX, Version 3.14159265-2.6-0.999991 (TeX Live 2019) (preloaded format=xelatex 2019.5.8)

What do I need to change?

  • 1
    \fontfamily{monofont}\selectfont should be just \ttfamily Commented Feb 28, 2021 at 19:58
  • 4
    just use \ttfamily and things will be monospace for the rest of the current group, this is standard latex not xetex specific Commented Feb 28, 2021 at 19:59
  • If you want the output to look like a classic IBM typewriter, you might try \setmonofont{TeX Gyre Cursor}[Scale=MatchUppercase]. Or your typewriter font of choice. That one is a clone of Courier.
    – Davislor
    Commented Mar 31, 2021 at 2:26

1 Answer 1

  1. The default font for \texttt is Computer Modern Typewriter.

  2. To use that font you can use \ttfamily to select the Computer Modern Typewriter family (Latin Modern Typewriter in XeTeX to allow for enhanced Unicode support).

  3. (and 4.) There is no font family called monofont. As a result, you got the warning:

    LaTeX Font Warning: Font shape `TU/monofont/m/n' undefined
    (Font)              using `TU/lmr/m/n' instead on input line 15.

which indicates that it's substituting Latin Modern Roman (LaTeX's default fallback for a missing font).

You must log in to answer this question.

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