[texhax] Rotating tables in pdf

Tom Schneider toms at ncifcrf.gov
Thu Nov 15 15:02:42 CET 2007


Diego:

> Thank you for your help on rotating tables of a few weeks back.

You're welcome.

> It's helped me to understand what may be going on here, but I'm still 
> puzzled. You say you fixed the problem changing "90 rotate" to "45 
> rotate 45 rotate," but in the sidewaystable environment there is (so far 
> as I know) no option to specify this. Everything just works by itself.
> 
> My code is:
> 
> \begin{sidewaystable}
> \centering
> \setlength{\extrarowheight}{8pt}
> \begin{tabularx}{\linewidth}{|X|X|X|X|}
> \hline
> <TABLE CONTENTS HERE>
> \hline
> \end{tabularx}
> \caption{CAPTION TEXT HERE.}
> \label{ether-summary}
> \end{sidewaystable}
> 
> Could you still explain how you implement your two-rotation trick?
> 
> Thank you!
> 
> Diego

going back to what I wrote:

> > I don't know a complete solution, but it seems to be that Adobe is
> > trying to make their display 'smart'.  It detects the rotate
> > PostScript command and rotates the image.  The way I got around it in
> > my PostScript code was by changing
> > 
> >    90 rotate
> > 
> > to
> > 
> >    45 rotate 45 rotate
> > 
> > as their 'smart' program isn't SO smart as to add the two rotations
> > ...  and this solved the problem for me!

Notice the words "PostScript code".  I was using includegraphics for
an eps or ps file.  So I could control the phrase '90 rotate' and I
discovered that that's what Adobe Reader was looking for.  As I
recall, putting '89.99 rotate' would fool it but, of course, slightly
mess up my figure.

It may be that you can do something equivalent.  If you convert your
file from dvi to ps, you may use grep (unix search tool) to see if '90
rotate' exists in the ps.  If so you could replace it:

% dvips file.dvi
  should give file.ps (I'm ignoring flags you may want to use).  Then:

% grep '90 rotate file.ps
  If they exist you will see them here.

% cat file.ps | sed 's/90 rotate/45 rotate 45 rotate/' > fixed.ps

of course if they are -90 rotate you would need:

% cat file.ps | sed 's/-90 rotate/-45 rotate -45 rotate/' > fixed.ps
o

I tested this and used:

cat paper.ps |\
sed 's/-90 rotate/-45 rotate -45 rotate/' |\
sed 's/90 rotate/45 rotate 45 rotate/' |\
cat > fixed.ps

while conversion of paper.ps to paper.pdf caused rotation of the page,
conversion of fixed.ps to fixed.pdf did not.  However, my figure
was rotated oddly and that I don't understand.  (Maybe I missed
something.)

In any case, this demonstrated that I could indeed apply the above
trick to fool the Adobe Reader.

So it might work on your sideways table.

... I tried it on my own table (yours has too many dependencies).

#!/bin/tcsh -f
#(ie run the tshell on this but don't read the .cshrc or .tcshrc)
echo version = 1.00 of fix 2007 Nov 15
# 2007 Nov 15, 1.00: origin 
set rot = 45
set rot = 25
cat paper.ps |\
sed "s/-90 rotate/-$rot rotate -$rot rotate/" |\
sed "s/90 rotate/$rot rotate $rot rotate/" |\
sed "s/90 neg rotate/$rot neg rotate $rot neg rotate/" |\
cat > fixed.ps
ps2pdf fixed.ps
open fixed.pdf

That did control the rotation and stopped the page from turning, but
with rotation of 45 it failed.

Ok, maybe it's smart enough to know about 45 rotations.  So I tried this:

#!/bin/tcsh -f
#(ie run the tshell on this but don't read the .cshrc or .tcshrc)
echo version = 1.00 of fix 2007 Nov 15
# 2007 Nov 15, 1.00: origin 
set rot = 25
set rot = 45
set rot1 = 44
set rot2 = 46
cat paper.ps |\
sed "s/-90 rotate/-$rot1 rotate -$rot2 rotate/" |\
sed "s/90 rotate/$rot1 rotate $rot2 rotate/" |\
sed "s/90 neg rotate/$rot1 neg rotate $rot2 neg rotate/" |\
cat > fixed.ps
ps2pdf fixed.ps
open fixed.pdf

That works!!  The page is NOT rotated, but the table is sideways!

Tom

  Dr. Thomas D. Schneider
  National Institutes of Health
  National Cancer Institute
  Center for Cancer Research Nanobiology Program
  Molecular Information Theory Group
  Frederick, Maryland  21702-1201
  toms at ncifcrf.gov
  permanent email: toms at alum.mit.edu
  http://www.ccrnp.ncifcrf.gov/~toms/


More information about the texhax mailing list