[Tex/LaTex] Specifying proportional numbers when using Libertine with pdfLaTeX

libertinepdftex

If I use the Libertine fonts from within XeLaTeX I can specify the use of proportional numbers/figures by including it as an option when I set the main font like so:

\setmainfont[Numbers={Lining,Proportional}]{Linux Libertine O} 

However, I'm also interested in being able to using proportional numbers when using pdfLaTeX. Below is a MWE that shows one way to do this. My "solution" seems awfully ugly though. Is there a better way to accomplish this?

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}

\begin{document}
% this seems necessary to get proportional numbers in Libertine
% when using pdflatex. Comment / uncomment to see the difference    
\usefont{T1}{fxlf}{m}{n}\selectfont    

I would like the following numbers to be proportional so that 11, 
doesn't take up as much space as 17. See what I mean?    

\end{document}

Best Answer

Here’s an answer for the current libertine version of 2014/11/25, since lockstep’s answer doesn’t work anymore with this current version (probably due to the changes in maintainer and conception since 2011).


Generally, Linux Libertine’s digits are either proportional (different widths) or tabular (same widths), and either oldstyle (different heights) or lining (same heights):

By default, i.e. if you don’t change anything, libertine uses tabular lining figures.

You can specify the style of numbers in three different ways, which have different ranges.

Package options – global effect

  • oldstyle (or osf) for old-style figures
  • lining (or nf or lf) for lining figures
  • proportional (or p) for varying-width figures
  • tabular (or t) for fixed-width figures

These apply to the entire document. Of course, it only makes sense to specify either oldstyle or lining, and either proportional or tabular. Example:

\usepackage[oldstyle, proportional]{libertine}

\fontfamily{…} – local effect

This way is not described in the libertine documentation.

  • proportional oldstyle figures: \fontfamily{LinuxLibertineT-OsF}\selectfont 123
  • proportional lining figures: \fontfamily{LinuxLibertineT-LF}\selectfont 123
  • tabular oldstyle figures: \fontfamily{LinuxLibertineT-TOsF}\selectfont 123
  • tabular lining figures: \fontfamily{LinuxLibertineT-TLF}\selectfont 123

These commands are placed in the document body, not in the preamble, and they change the font starting at the point where they’re placed. For more details on how to use these commands, have a look at the LaTeX answer to How do I use a particular font for a small section of text in my document?. Example:

123 tabular lining figures (default) up to here
\fontfamily{LinuxLibertineT-LF}\selectfont
123 proportional lining figures from now on

Macro – small, selective effect

  • \oldstylenums{123}
  • \liningnums{123}
  • \proportionalnums{123}
  • \tabularnums{123}

These macros only change the style of the numbers in the argument. Example:

123 tabular lining figures (default), but then \oldstylenums{123
(still tabular) oldstyle figures} and back to 123 tabular lining
figures