# How can I use the slanted variant of the libertine font?

In standard packages with the Texlive distribution on Debian 7 (Wheezy), I was able to produce slanted text with the Linux Libertine font by calling text as \textsl{slanted text here}.

I have upgraded to Debian 8 (Jessie) and it seems the Libertine package does not support slanted text anymore. Everywhere I call \textsl{} the output is merely italic. I have installed all the variants of Libertine on my operating system (as OTF) and I have access to Linux Libertine Display Slanted O through LibreOffice and other programs.

This is most regrettable, because I use slanted text a lot for keywords in large scientific documents.

Is there a way for me to configure LaTeX so that I have access to slanted Libertine, or a similar font that fits well within regular Libertine text?

MWE which produces only italic when compiled with pdflatex:

\documentclass{article}
\usepackage{libertine}

\begin{document}

Here is some \textit{italic} text,
and what should be \textsl{slanted} text.

\end{document}


• Slanted variants are no supported for libertine but you can use small caps... page 2 at mirror.ctan.org/fonts/libertine/doc/libertine.pdf – juanuni Aug 9 '15 at 14:35
• @juanuni I have read this document, and also tried messing about with the .fd files that come in the package, to no avail. Yet I have compiled documents daily for an entire year with slanted libertine text in them (the PDFs had a LinLibertineSlanted font embedded). – doobadooba Aug 9 '15 at 17:00
• @doobadooba: There is no official Libertine Slanted, but it's possible that an earlier version of the libertine package provided an artificially slanted variant. If you want that you'll have to install the libertine-legacy package from CTAN. – user51830 Aug 9 '15 at 19:07
• @user51830: indeed, this looks like it could solve my problem (the log files from my old, successful pdflatex compilations refer to libertine-legacy). But so far, six hours into it, I cannot manage to install that package properly on my new operating system: I keep running into LaTeX Font Warning: Font shape OT1/fxl/m/n' undefined problems. Would you have any pointers? – doobadooba Aug 11 '15 at 7:18
• @user51830: a few more hours, and I made it work (see selected answer below), thank you! – doobadooba Aug 11 '15 at 19:08

There is no slanted font in the Linux Libertine distribution. You can do like LibreOffice does and fake the slanting geometrically.

\documentclass{article}
\usepackage{libertine}

\makeatletter
\setmainfont[
Extension=.otf,
Numbers        = {\libertine@figurealign,\libertine@figurestyle},
UprightFont    = *_R,
ItalicFont     = *_RI,
BoldFont       = *_\libertine@boldstyle,
BoldItalicFont = *_\libertine@boldstyle I,
SlantedFont    = *_R,
SlantedFeatures = {FakeSlant=0.25},
]{\libertine@base}
\makeatother

\begin{document}

Here is some \textit{italic} text,
and what should be \textsl{slanted} text.

\end{document}


• pdflatex will not compile this document (undefined control sequence on the \setmainfont). I take it you used lualatex? – doobadooba Aug 9 '15 at 15:39
• @doobadooba Yes, this works both for XeLaTeX and LuaLaTeX. There's no slanted font for pdflatex; adding support for geometrical slant is not conceptually difficult, but would require extensive work. – egreg Aug 9 '15 at 16:01
• hmmm… Switching to LuaLaTeX brings problems of its own, too (hyphenation issues, different font for numbers in equations), and my largest document has a 20-minute pdflatex compilation routine : the switch is time-expensive. I will try some more in the coming evenings. Thank you for your time! – doobadooba Aug 9 '15 at 16:56
• your solution also changes all my \emph{} into slanted text. how can I modify it that \emph{} will be omitted and displayed as italics? – LukasCB Sep 5 '16 at 16:23
• @LukasCB I get italics for \emph; this is the picture (click here) I get with \emph{different} \textit{different} \textsl{different} – egreg Sep 5 '16 at 16:35

Another option is to use Bruno's \slantbox (Shear transform a "box") as a substitute for \textsl. I have set the default slant to 0.2.

\documentclass{article}
\newsavebox\foobox
\newcommand{\slantbox}[2][.2]{\mbox{%
\sbox{\foobox}{#2}%
\hskip\wd\foobox
\pdfsave
\pdfsetmatrix{1 0 #1 1}%
\llap{\usebox{\foobox}}%
\pdfrestore
}}
\def\textsl#1{\slantbox{#1}}
\usepackage{libertine}

\begin{document}

Here is some \textit{italic} text,
and what should be \textsl{slanted} text.

\end{document}


• Impressive! I regret that I cannot test this easily anymore, having switched to libertine-legacy. – doobadooba Aug 11 '15 at 19:06
• @doobadooba You might still be able to test it. Since it redefines \textsl, then any resulting slant would be the result of this approach applied to upright shape, rather than a font variant. To really test it, change the default slant to, let's say, 0.5 and see if it slants more in your test. – Steven B. Segletes Aug 11 '15 at 19:09
• @steven-b-segletes indeed! This is a very good solution. The resulting slant is, in my eyes, identical, and I cannot feel a compilation time overhead. Many thanks! – doobadooba Aug 24 '15 at 8:33
• I was able to test this solution further. I met two problems: #1, slanted text within italic text is "doubly sheared" (a minor problem); and #2 slanted text tends to overflow into margins, because the mbox prevents line breaks from occurring between words. These two limitations make the (cumbersome) manual installation of the libertine-legacy package a better solution. Many thanks for your proposition. – doobadooba Sep 17 '15 at 19:09
• @doobadooba Thanks for the consideration. It is a good point to note that hyphenation breaks with this approach. The only workaround (not fix) to that is to use \sloppy or the sloppypar environment. – Steven B. Segletes Sep 17 '15 at 19:15

The solution is to install the libertine-legacy (TeX) package, as @user51830 pointed out. The current (2015-08) libertine package is a dummy package which points to libertineotf or libertine-type1 depending on the compiler that calls it, but even though it “serves the purpose” of libertine-legacy, it does not replace it fully and in particular it does not contain slanted text.

If you want slanted libertine text, but only want to use pdflatex, you need libertine-legacy. On Debian 8 there is no deb package for this and the install needs to be done manually. This does not require removing any existing TeX or Debian package from the system.

The following procedure worked for me (although some steps are probably dispensable):

1. Download a libertine-legacy.tds.zip archive from an old mirror. (no, the libertine-legacy.zip package from CTAN will not work!) I found mine on the UChicago website through Google. Extract all of its files in your local TEXMF path (mine was at /usr/local/share/texmf/).
2. Among these new files, install all the fonts in fonts/type1/public/libertine-legacy to your operating system (by double-clicking on them or by copying them to your ~∕.fonts/ folder).
3. Check that your new libertine-legacy package takes precedence over any other libertine instance on your system by typing kpsewhich libertine.sty which should return the path to your freshly-added files. If it does not, delete all the intruders.
4. Run mktexlsr and then updmap-sys enable Map libertine.map (you may need administrator rights for this).

You should now be able to compile the following file with pdflatex:

\documentclass{article}
\usepackage[T1]{fontenc} % note this addition: else libertine will default
% to OT1 fonts, and will fail
\usepackage{libertine}

\begin{document}

Here is some \textit{italic} text,
and what should be \textsl{slanted} text.

\end{document}
`