Tag Archive

amateur astronomy awk bash be b[e] supergiant cartoon conference convert evolved star exoplanet fedora figaro fits fun galaxy history iraf jupiter latex linux lmc machine learning massive star matplotlib meteor mypaper paper peblo photometry planet pro-am pyraf python scisoft skinakas observatory small magellanic cloud smc spectroscopy starlink talk theli ubuntu university of crete video x-ray

ps2pdf behavior regarding page orientation with eps images

While writing a paper I was puzzled to see that although I was not putting anything in LaTeX code to affect the orientation of the page (Image 1), some pages were rotated at the final pdf file (Image 2). But why was that? Although I did play around to see if there was something wrong with the images, or the code, or whatever could possible go wrong with the LaTeX, the output was the same.


Image 1: The LaTeX code – nothing unusual here, just inserting some figures.


Image 2: The final pdf output. Clockwise: (1) a page with text, (2) a page with some figures properly shown, (3) the problematic page – it should be oriented as portrait and not landscape, (4) the next page with, properly displayed, plots.

From the final pdf document (Image 2, “page” 3) it is obvious that LaTeX does not do anything wrong. The page has the proper portrait orientation, but the pdf page is rotated. Looking around to see what could go wrong with the ps2pdf conversion I found out that:
“By default Ghostscript determines viewing page orientation based on the dominant text orientation on the page. Sometimes, when the page has text in several orientations or has no text at all, wrong orientation can be selected.” [1]

Since the images used are eps files [2], which means that they are text files, and they have plenty of text vertically oriented, Ghostscript takes their orientation as the proper one. When I manually run:
ps2pdf -dAutoRotatePages=/None file.ps file.pdf
these orientation issues removed.

Another idea is to use some extra invisible text (like white text in a white background) in order to increase the horizontal text. That way Ghostscript will select the right orientation from the beginning. A way to do it is presented in [3], but in my case it didn’t work well as it was also increasing the length of caption resulting in its displacement. Moreover, if highlighted the text become visible.

[1] Ps2pdf/Orientation
[2] wikipedia.org/EncapsulatedPostScript
[3] TeX-stackexchange.com/phantom-and-line-break

Manipulating postscript/pdf files

Postscript files (.ps) are usual and in many cases some manipulation is needed. [for more see also here]

Convert from a ps to pdf file:
$ ps2pdf input_file.ps output_file.ps

Merge 2 or more files:
$ psmerge -ooutput_file.ps input_file_1.ps input_file_2.ps [more_files]
note: that -o and output_file’s name are not separated by any space

Put more pages per page:
$ psnup [options] -n input_file.ps output_file.ps
[options]: -l , -r which “corrects” for orientation
-n: number of pages from input_file.ps that will be on a single page of output_file.ps (for example -2 for 2 pages/new page, -4 for 4, etc.)