For part of my documentation I want my \texttt to use a fixed-spacing font that slashes its zeroes. The default font LaTeX uses for the purpose (Courier New, I suppose) does not. I'm used to Consolas for this purpose, but I don't suppose it matters much. How do I set the default tt font?

(I looked up this question and found a reference to \setmonofont, but \setmonofont{Consolas} generates an error message about an undefined control sequence; I suspect \setmonofont is for lua only.)

  • Welcome to LaTeX! I think most monospaced fonts let you choose whether or not you use slashed zeroes. It is usually an available OpenType feature. Commented Jan 8, 2023 at 22:23

3 Answers 3


You could use inconsolata.

  • 1
    Hey, that looks good! Only one problem: It doesn't respond to \textit, which I need to use for variables. Sigh. (But thanks anyway.) Commented Jan 8, 2023 at 22:29
  • 1
    Is your text in math mode? If so, try \mathit. Commented Jan 8, 2023 at 22:36
  • You can also try the iosevka font with lualatex (be warned, that font is a monster. Expect a lot of delay the first time you compile to build the caches...)
    – Rmano
    Commented Jan 9, 2023 at 7:42

The \setmonofont command works in either LuaLaTeX or XeLaTeX if you


You probably want


or possibly


But be aware, Consolas is not a free font. If you do this, other people will only be able to recompile your document from source on a machine with Microsoft Windows or Microsoft Office installed.


As illustration of using OTF font features with fontspec, TeX Gyre Cursor font is a fixed-width font which has the slashed-zero OpenType font feature.


You can use any suitable font instead.



\setmonofont{Tex Gyre Cursor}[Numbers=SlashedZero]
\newfontfamily\fontcons{Tex Gyre Cursor}[Numbers=SlashedZero]

\newcommand\sample[1]{{\fontcons#1abc \digits\ xyz iiii mmmm}}

As document mono-spaced font: 





As custom font family

A. \sample{}

B. \sample{\itshape}

C. \sample{\bfseries}

D. \sample{\itshape\bfseries}


You must log in to answer this question.

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