[Tex/LaTex] Slanted text to the left

fontsslanted

How can I get slanted text to the left instead?
Instead of the usual way slant/italic slants to the right.

Best Answer

Taking Bruno's answer at Shear transform a "box", \slantbox[slant]{text} will give leftward slant for negative values of slant. The larger the absolute value of slant, the more the slant. I'm speculating that the value of slant is the tangent of the slant angle, relative to the vertical aspect.

The default is no slant, but once slant is set with the optional argument, it will persist for future invocations at that value until changed again in the optional argument.

This EDITED solution will line wrap. The code has be RE-EDITED to restore kerning and ligatures, by processing words, rather than characters at a time. However, hyphenation is not possible.

\documentclass{article}
\newsavebox\foobox
\def\slantvalue{0}
\newcommand{\slantboxengine}[2][\slantvalue]{\mbox{%
        \sbox{\foobox}{#2}%
        \hskip\wd\foobox
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\foobox}}%
        \pdfrestore
}}
\newcommand\slantbox[2][\slantvalue]{%
  \edef\slantvalue{#1}\expandafter\slantboxhelpA#2 \relax\relax}
\def\slantboxhelpA#1 #2\relax{%
  \slantboxengine{#1}%
  \ifx\relax#2\relax\else\ \slantboxhelpA#2\relax\fi
}
\begin{document}
\slantbox[-.3]{%
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.}

The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.

NEW METHOD RESTORES LIGATURES

\slantbox{fififififi flflflflfl}

PRIOR METHOD:

\def\slantboxhelpA#1 #2\relax{%
  \slantboxhelpB#1\relax\relax%
  \ifx\relax#2\else\ \slantboxhelpA#2\relax\fi
}
\def\slantboxhelpB#1#2\relax{%
  \slantboxengine{#1}%
  \ifx\relax#2\else
    \slantboxhelpB#2\relax%
  \fi
}
\slantbox{fififififi flflflflfl}

\end{document}

enter image description here

Related Question