Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sideways text

37 views
Skip to first unread message

Doug McDonald

unread,
Mar 12, 1990, 6:58:58 PM3/12/90
to

I am trying to get text output sideways (i.e. a line of text
rotated 90 degrees or 270 degrees so it would read normally if you
rotated the output sheet 90 degrees). This should be easy if
you are outputting to Postscript, and indeed would be expected to be
on the top of the list of possible enhancements to TeX. I can do it
by hacking the Postscript output of dvips. But I can't think of
a way to do it with specials. I am here talking about regular cm fonts.

Anyone know the answer?

Doug McDonald

Tomas G. Rokicki

unread,
Mar 12, 1990, 7:46:33 PM3/12/90
to
dvips contains macros for rotating text. I've included them below; they
should work for any recent version of dvips.

---rotate.tex---
%
% These macros allow you to rotate or flip a \TeX\ box. Very useful for
% sideways tables or upsidedown answers.
%
% To use, create a box containing the information you want to rotate.
% (An hbox or vbox will do.) Now call \rotr\boxnum to rotate the
% material and create a new box with the appropriate (flipped) dimensions.
% \rotr rotates right, \rotl rotates left, \rotu turns upside down, and
% \rotf flips. These boxes may contain other rotated boxes.
%
\newdimen\rotdimen
\def\vspec#1{\special{ps:#1}}% passes #1 verbatim to the output
\def\rotstart#1{\vspec{gsave currentpoint currentpoint translate
#1 neg exch neg exch translate}}% #1 can be any origin-fixing transformation
\def\rotfinish{\vspec{currentpoint grestore moveto}}% gets back in synch
%
% First, the rotation right. The reference point of the rotated box
% is the lower right corner of the original box.
%
\def\rotr#1{\rotdimen=\ht#1\advance\rotdimen by\dp#1%
\hbox to\rotdimen{\hskip\ht#1\vbox to\wd#1{\rotstart{90 rotate}%
\box#1\vss}\hss}\rotfinish}
%
% Next, the rotation left. The reference point of the rotated box
% is the upper left corner of the original box.
%
\def\rotl#1{\rotdimen=\ht#1\advance\rotdimen by\dp#1%
\hbox to\rotdimen{\vbox to\wd#1{\vskip\wd#1\rotstart{270 rotate}%
\box#1\vss}\hss}\rotfinish}%
%
% Upside down is simple. The reference point of the rotated box
% is the upper right corner of the original box. (The box's height
% should be the current font's xheight, \fontdimen5\font,
% if you want that xheight to be at the baseline after rotation.)
%
\def\rotu#1{\rotdimen=\ht#1\advance\rotdimen by\dp#1%
\hbox to\wd#1{\hskip\wd#1\vbox to\rotdimen{\vskip\rotdimen
\rotstart{-1 dup scale}\box#1\vss}\hss}\rotfinish}%
%
% And flipped end for end is pretty ysae too. We retain the baseline.
%
\def\rotf#1{\hbox to\wd#1{\hskip\wd#1\rotstart{-1 1 scale}%
\box#1\hss}\rotfinish}%
---rotate.tex---
---rotsample.tex---
\input rotate
\newbox\rottwo
%
\font\big=cmr17 scaled\magstep4
This is a \setbox\rotbox=\hbox{simple}\rotl\rotbox\ test of
\setbox\rotbox=\hbox{some}\rotu\rotbox\ rotation primitives that
\setbox\rotbox=\hbox{\big work}\rotr\rotbox.
Or maybe \setbox\rotbox=\hbox{\vrule height .2in width .2in}\rotl\rotbox\
not.
\bigskip
\centerline{\vbox{\offinterlineskip
\def\tablerule{\noalign{\hrule}}
\def\allfive#1{&\global\setbox\rottwo=\hbox{\strut#1}\copy\rottwo&&%
\setbox\rotbox=\copy\rottwo\rotl\rotbox&&%
\setbox\rotbox=\copy\rottwo\rotu\rotbox&&%
\setbox\rotbox=\copy\rottwo\rotr\rotbox&&%
\rotf\rottwo&\cr\tablerule}
\halign{\vrule#&\hfil\ #\ \hfil&\vrule#&\hfil\ #\ \hfil&\vrule#&%
\hfil\ #\ \hfil&\vrule#&\hfil\ #\ \hfil&\vrule#&\hfil\ #\ \hfil&\vrule#\cr
\tablerule
&\strut Upside&&Leftside&&Rightside&&Downside&&Flipside&\cr\tablerule
\allfive{\strut gnus}
\allfive{$-b-\sqrt{b^2-4ac}\over2a$}
\allfive{{\big A}}}}}%
\bye
---rotsample.tex---

Simon Tortike

unread,
Mar 12, 1990, 9:52:03 PM3/12/90
to
In article <1990Mar13....@Neon.Stanford.EDU> rok...@Neon.Stanford.EDU (Tomas G. Rokicki) writes:
>dvips contains macros for rotating text. I've included them below; they
>should work for any recent version of dvips.
>
>---rotate.tex---
>%
>% These macros allow you to rotate or flip a \TeX\ box. Very useful for
>% sideways tables or upsidedown answers.
>%

I tried these macros and the sample using TeXtures v1.2 on the Macintosh with
System 6.0.4 and LaserWriter 6.0, having changed the `ps: ` to
`postscript\ `, without any success. Can anyone suggest a reason for this?
Thanks,
-------------------
W. Simon Tortike, | tel : 403/492-3338
Dept of Mining, Metallurgical | fax : 403/492-7219
and Petroleum Engineering, | CDNnet : si...@cs.UAlberta.CA
University of Alberta, | uucp : si...@alberta.uucp
Edmonton, AB, CANADA T6G 2G6. |

0 new messages