# Ubuntu Font in LaTeX

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

Eg.

-
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 5 '14 at 17:50
As @percusse says. Just install the font and then use LuaLaTeX or XeLaTeX. Lots of questions explain how. – cfr Apr 5 '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 5 '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 5 '14 at 18:11
For users not using Ubuntu: The whole font family is available on Ubuntu Font Family – or at Google Fonts google.com/fonts . – Speravir Apr 5 '14 at 23:13

## 2 Answers

I think it is probably 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:

\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:

-

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}

-
It is not the right font, though. Compare the 'i's ;). – cfr Apr 5 '14 at 20:53