Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use LyX for creating documents and would like to be able to format the output of my documents so that they use the Ubuntu font.

In the LyX document settings, it appears that there are only a fixed number of fonts available.

LyX: Document Settings

Is it possible to add the Ubuntu font to this list?

If not, is there a way to use the Ubuntu font in LaTeX? I can export the LyX document to LaTeX, make my changes and then use pdflatex & co. to create a formatted document.

share|improve this question
add comment

6 Answers 6

up vote 11 down vote accepted

Converting a font in the true type format (like the Ubuntu font) to the format LaTeX understands is possible with tools such as ttf2afm, ttf2pk etc. but involves a lot of work. There are many howtos on the net (e.g. this one).

An alternative is using XeTeX instead of LaTeX/pdfLaTeX, which is capable of using any system font. It's also not too difficult to get LyX working with XeTeX, the LyX wiki has a howto: http://wiki.lyx.org/LyX/XeTeX

Update: Vincent-Xavier Jumel posted a very concise summary of how you can convert the Ubuntu fonts to a LaTeX package in a blog post. You can then simply use \usepackage{Ubuntu} in LaTeX or LyX.

share|improve this answer
    
Thanks. XeTeX works great. –  dv3500ea Oct 19 '10 at 18:32
    
+1, XeTeX is generally fantastic and properly understands Unicode to boot. –  loevborg Jan 13 '11 at 15:19
add comment

To use the Ubuntu font (or any other system font), use XeTeX Install texlive-xetex.

Once you have created your document in LyX, add some TeX code at the start of the document (using the TeX button): \fontspec{Ubuntu}. This makes the whole document use the Ubuntu font. If you want to switch to another font at some point use the \fontspec command again with the font name of the other font.

LyX document

To allow this to render to a DVI/PDF/etc., some settings need to be changed in Document>Settings.

Click on 'LaTeX Preamble' and enter this into the text box:

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}

LaTeX Preamble

Also, under 'Language', set the encoding to Unicode (XeTeX) (utf8).

Language

Now export the document as LaTeX(pdflatex):

export

This will appear to do nothing but will actually output to DOCUMENT_NAME.tex.

Now open a teminal (Applications->Accessories->Terminal) and enter:

cd ~/Documents
xelatex ubuntu.tex
xdg-open ubuntu.pdf

Replace ~/Documents with the path of the folder containing your document and ubuntu with the name of the document. This should create a PDF file of the output of your document and open it in the default PDF reader:

PDF output

Doesn't it look pretty? :D

Thanks to Marcel Stimberg for suggesting XeTeX and providing the useful links to resources. I suggest people to have a look at those for more details.

share|improve this answer
    
Nice explanation! I think it should be possible to directly call xetex from LyX (i.e. instead of exporting first), but I never tried that. –  Marcel Stimberg Oct 19 '10 at 20:51
1  
Wow, a perfect answer! One question remains to me: How is the typographic quality of the font use. Does it have the typical benefits of LaTeX, like better kerning? –  Ingo Jan 6 '11 at 10:57
add comment

I've made a bundle of the Ubuntu Font Family for LaTeX2e. You can download it from github:

https://github.com/tzwenn/ubuntu-latex-fonts

For installation just run:

sudo make install

and then type \usepackage{ubuntu} in your LaTeX file.

share|improve this answer
    
Does this also support math? –  joris May 24 '11 at 22:44
    
No, this package replaces your default Roman font set. The mathmode does not make use of it and even includes glyphes that are not part of the Ubuntu Font Family. –  tzwenn Jun 7 '11 at 13:36
add comment

On 12.04 I enabled in the Lyx UI as follows:

  • install packages: texlive-xetex and etoolbox
  • in Lyx: Tools > Reconfigure
  • close Lyx and restart
  • Document > Settings > Fonts > Use non-Tex fonts
share|improve this answer
add comment

Since LaTeX/TeX uses fonts that are created with Metafont, I would think the Ubuntu font must be put into a format that Metafont can use and create its internal font information from. In turn you need to then use the Metafont created font files to create the dvi files from your LaTeX source files.

share|improve this answer
add comment

Beginning with the 2.0.x series LyX has built-in support for XeTeX/LuaTeX. To use the Ubuntu font you simply need to Doc > Settings > Fonts > Use non-TeX fonts, then select Ubuntu font from the combo. (The accepted answer gives a more complicate solution than necessary.)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.