I came across a problem with pdflscape
and TikZ' external
library where externalized tikzpicture
s in a landscape
environment were rotated incorrectly ( Using tikzexternalize with pdflscape results in rotated image). Apparently, this is a known bug (added to the pgfplots
"to-do" list in 2009).
In my case, it turns out that everything works fine if I use \usepackage[pdftex]{lscape}
instead of \usepackage{pdflscape}
: The landscape page is correctly rotated and displayed in the PDF viewer, and the externalized image is oriented correctly.
Is there a reason why I should not use [pdftex]{lscape}
instead of the {pdflscape}
package? It seems that both do the same thing (make sure that landscape pages are displayed in landscape mode in the viewer). However, on the lscape
CTAN page it says:
Note that the package makes no special provision for PDF output, where
in principle a single page can be shown at full landscape width; such
an effect may be achieved using thepdflscape
package instead.
Why does the lscape
package recommend using pdflscape
instead of its own pdftex
switch?
Best Answer
Answering the various points "why does
lscape
package recommend a different package" well it doesn't really. The ctan catalog package descriptions are not (in general) by the package authors but a third party review of the package.There are three places that "rotation" can occur when considering a page in a pdf file.
lscape
only considers one of them [* see note at end about[pdftex]
option] andpdflscape
considers two.To make a page landscape you need to:
first switch round
\textheight
and\textwidth
(and a few other associated lengths). That much you can do in pure TeX.Then you need to rotate the text box on to the page (since lscape doesn't move the page numbers) This is done by using
\rotatebox
from the graphics package and so needs driver dependent code specified by a package option or defaulted fromgraphics.cfg
.For printing, that's all you need, but for viewing you might want to rotate the "entire page" the other way so that on-screen the main text is vertical and the effect is that the page outline is rotated to landscape.
pdflscape
inserts additional code to rotate the view in the viewer.But ... some pdf viewers use heuristics to determine the orientation of the "main" text on a page and rotate the page view even when not explicitly specified.
As far as I know you can't reliably rotate the page view in ways that work for all configurations of all viewers. If as in the original
lscape
you ignore the issue the page will look fine if using a viewer that auto-rotates and the page has sufficient text that it can tell which way is up (It's harder to tell which is up for images). If you force the view to rotate as inpdflscape
then (I think) if the viewer auto-rotates the it gets rotated twice so ends up the wrong way up. It would be nice to be able to say "this way up" but I don't think that's possible (and it isn't what either package does) you can only say "rotate the view" from a default that might change depending on the viewer.At least I think that's the situation, I never actually used
pdflscape
but I had a quick look at its code while writing this:-)Ah. As noted above I checked the code for the "other" package but didn't check the code of "my" package. ...
So apparently back in 1999 I accepted a 3rd party diff so that
lscape
also affects the pdf page view attributes if used with[pdftex]
. Sorry the version in my head was the original:So I think that there effectively isn't any difference for pdftex but
pdflscape
adds equivalent code for many other driver back ends such as dvips or dvipdfm. Sorry about the confusion.This also explains why you need to use
[pdftex]
explicitlylscape
handles that itself to add the code shown above. It would probably be better if instead it just letgraphics
handle the options and then make an internal check to see which driver backend graphics ended up using. That way it would also work if the graphics driver were defaulted fromgraphics.cfg
(as is usually the case with graphics package options).