25

I'd like to achieve something like in the picture below:

enter image description here

Another example:

enter image description here

Note that the text is not simply rotated! I know it could be achieved by boxing each character separately, measuring the height and then raising by the missing amount to reach e.g. 1em... But I'm sure there is a better way around.

I'd like a macro that works for a whole line for instance (a whole paragraph would be even better! :) ).

Edit: Ascenders should protrude (as descenders) unless they have some special feature, like 'striketrough' in a 't'. Capitals should not protrude.

5
  • Interesting question! Is this just for the novelty value, or do you have an actual application for this?
    – Jake
    Commented Sep 19, 2011 at 1:23
  • Something seems to be not quite right with your example picture: The ascender portion of the d becomes a descender after the rotation, but the t doesn't behave the same way (it should also protrude below the new baseline). How do you want the letters to behave? Should capitals protrude below the baseline? Should ascenders?
    – Jake
    Commented Sep 19, 2011 at 1:38
  • 1
    @Jake: This is an actual setting for Facebook's display text and I was curious how this would look like done in LaTeX. :) I think the guys from Facebook just wanted to turn the text upside-down, but there might be some bug in the way it finally is rotated.
    – Count Zero
    Commented Sep 19, 2011 at 1:53
  • 2
    For me the turned t does descend in Facebook. Probably depends on the font.
    – Caramdir
    Commented Sep 19, 2011 at 4:10
  • I don't see any way to solve this without scanning the input character by character and doing the rotation (and shifting in some cases). Probably easy in LuaTeX. :)
    – egreg
    Commented Sep 19, 2011 at 12:50

4 Answers 4

23

Thanks for all the answers! After doing some research myself and digging up some packages I never had used before, I also belive the input needs to be scanned charcter by character, as suggested by @egreg.

So here is a way of doing it in LaTeX:

\documentclass{minimal}

\usepackage{graphicx}
\usepackage{xstring}
\usepackage{forloop}

\begin{document}
\newcounter{idx}
\newcounter{posx}
\newcommand{\rotraise}[1]{%
  \StrLen{#1}[\slen]
  \forloop[-1]{idx}{\slen}{\value{idx}>0}{%
    \StrChar{#1}{\value{idx}}[\crtLetter]%
    \IfSubStr{tlQWERTZUIOPLKJHGFDSAYXCVBNM}{\crtLetter}
      {\raisebox{\depth}{\rotatebox{180}{\crtLetter}}}
      {\raisebox{1ex}{\rotatebox{180}{\crtLetter}}}}%
}
This is what I want to get.

\rotraise{This is what I want to get.}
\end{document}

Below you can admire the result. :)

enter image description here

2
  • Nice answer; I've taken the liberty of modifying it in order not to declare two new counters at each macro call.
    – egreg
    Commented Sep 19, 2011 at 14:04
  • @egreg: Thanks for your addition, much appreciated!
    – Count Zero
    Commented Sep 19, 2011 at 14:10
22

Here are a couple of possibilities, using the facilities of the graphicx package:

\documentclass{article}
\usepackage{graphicx}

\parindent0pt

\begin{document}

Upside down\\
\rotatebox{180}{Upside down} Upside down \\
\rotatebox{180}{\reflectbox{Upside down}} Upside down and mirrored \\
\raisebox{\depth}{\rotatebox{180}{Upside down}} Upside down and raised to fit in line

\end{document}

Or you could possibly vary the {\depth} with a number.. say 0.5em to align the text with other non-rotated texts

output of example code

0
19

Facebook doesn't actually turn the letters around, it just (ab)uses various characters Unicode provides (e.g. IPA characters). With XeLaTeX or LuaLaTeX and a suitable font, you can do the same:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{FreeSans}
\begin{document}
uʍop əpısdՈ
\end{document}

(Compile with xelatex or lualatex.)

The actual characters used here are:

u   latin small letter u
ʍ   latin small letter turned w
o   latin small letter o
p   latin small letter p
    space   
ə   latin small letter schwa
ı   latin small letter dotless i
s   latin small letter s
d   latin small letter d
Ո   armenian capital letter vo

The quality of the output is of course disputable.

2
  • 1
    Is there no way to do it in plain LaTeX?
    – Count Zero
    Commented Sep 19, 2011 at 9:26
  • This is plain LaTeX, just rendered using XeLaTeX or LuaLaTeX.
    – raphink
    Commented Sep 19, 2011 at 15:51
17

I was a bit surprised to learn that this isn't catered for in TikZ's text decorations. However, a judicious insertion of a \rotatebox in to the code at the correct point (I hope) led to:

upside down text

The code for that would be:

\documentclass{standalone}
%\url{http://tex.stackexchange.com/q/28861/86}

\usepackage{tikz}
\usetikzlibrary{decorations.transformedtext}

\begin{document}
\begin{tikzpicture}
\useasboundingbox (-1,1) -- (5,-1);
\path[decorate,decoration={transformed text along path,text={upside down}, text rotation=180}] (0,0) -- (5,0);
\end{tikzpicture}
\end{document}

if there was a PGF library pgflibrarydecorations.transformedtext.code.tex. The actual code for that is an extremely minor modification of pgflibrarydecorations.text.code.tex, but in order to make it an actual library it would need a little stress testing. For example, rotating the text only 90 degrees results in:

rotated text

which is missing the space (maybe the box containing a space has width but not height?), and could do with a little more separation between the characters.

Incidentally, although this looks neat, it is working in exactly the manner said: walking along the text, measuring each character, and typsetting it in the correct place. It's just that this code (almost) already exists, and can be used to do:

The Mouse's Tale

which, I'm sure, is what Lewis Carroll would have written had he known about TeX and TikZ.

3
  • 8
    If you can also progressively reduce the font size it would be better.
    – egreg
    Commented Sep 20, 2011 at 11:21
  • @Andrew Stacey: How can you work out the "walking along the text"? What TeX did you set up?
    – NasuSama
    Commented Sep 5, 2013 at 1:03
  • @NasuSama I'm afraid I don't understand the question. As I said in my answer, this involves a small modification of one of the TikZ libraries. The "walking along the text" is done by the text decorations library, the modification is to allow for a transformation of said text. Commented Sep 5, 2013 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .