11

How do I use the font provided by Ubuntu in LaTeX?

Eg.

enter image description here

subham soni
  • 9,673
  • 2
    Can you at least tell us the name of the font? Then there are lots of duplicates on this site for using system fonts – percusse Apr 05 '14 at 17:50
  • As @percusse says. Just install the font and then use LuaLaTeX or XeLaTeX. Lots of questions explain how. – cfr Apr 05 '14 at 17:57
  • @cfr Well, the font is installed already, as he uses it in that editor. Subham: If you don't know the name of the font, go into the preferences of the editor (Gedit?), you can find which font is used there I'd think. – Torbjørn T. Apr 05 '14 at 18:00
  • @TorbjørnT. Probably. But it does no harm to point it out. (After all, the OP might want to use the font on a different system or have found a screenshot on the web.) – cfr Apr 05 '14 at 18:11
  • 1
    For users not using Ubuntu: The whole font family is available on Ubuntu Font Family – or at Google Fonts http://www.google.com/fonts . – Speravir Apr 05 '14 at 23:13
  • Yes, I've tried \usepackage{fontspec} with xelatex and \setmonofont{Ubuntu} and \setmonofont{Ubuntu Mono} but it does not give me all the unicodes in the PDF that I do get in the terminal? – Dave R. Cole Mar 30 '18 at 13:02

2 Answers2

14

I think it is probably Ubuntu Mono:

Ubuntu Mono

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Ubuntu Mono}
\usepackage{kantlipsum}

\begin{document}

\kant[1]

\end{document}

If you don't want to use it as the main font for the document, fontspec allows you to configure it for specific uses or as your 'typewriter' font.

For example, you might want Ubuntu Mono as your 'typewriter' font and Ubuntu for sans:

Ubuntu and Ubuntu Mono for sans and typewriter

\documentclass{article}
\usepackage{fontspec}
\setsansfont{Ubuntu}% Ubuntu as sans - use \sffamily or \textsf{} as normal
\setmonofont{Ubuntu Mono}% Ubuntu Mono as 'typewriter' - use \ttfamily or \texttt{}
\usepackage{kantlipsum}

\begin{document}
\thispagestyle{empty}

{\noindent\sffamily Ubuntu:

\kant[1]}

{\noindent\ttfamily Ubuntu Mono:

\kant[2]}

\end{document}

If you want to use Ubuntu Mono for certain elements but not set it up as the default anything, you can specify a command to switch to it:

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\ubuntumono{Ubuntu Mono}

\begin{document}
\thispagestyle{empty}

This is some text in the regular font.

{\ubuntumono This is some text in Ubuntu Mono.}

\end{document}

This produces the following (rather ugly) output but demonstrates the idea:

Ubuntu Mono via \ubuntumono

cfr
  • 198,882
3

You can use any system font with the xetex or luatex engines with the fontspec package as a nice interface.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Ubuntu}
\begin{document}
The lazy fox jumpes over the brown dog.
\end{document}
Toscho
  • 4,713