3

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

migrated from stackoverflow.com Nov 6 '14 at 19:19

This question came from our site for professional and enthusiast programmers.

  • 2
    have you tried anything yet? – Darpan Oct 14 '14 at 7:36
  • Not, yet. Looked around on the internet but couldn't seem to find anything. It's for a personal project so I didn't want to lose hours of time if anyone just knew the answer. – striker Oct 14 '14 at 7:54
  • 1
    Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Nov 6 '14 at 19:24
  • What font? Slant is normally a property of the font. If it's a Metafont, you could do this; but we need more information to help. – dgoodmaniii Nov 6 '14 at 19:55
  • Related: How do I get fake slant (italics) with XeLaTeX? – Werner Nov 6 '14 at 20:41
6

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy