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.

latex2pdf-1

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

latex2pdf-2

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

MNRAS and eps font type

I was ready to submit my revised version at the MNRAS site, when I encountered some difficulties that I didn’t expected (although I knew that there would be some!).

So, you have to upload a complete file of your paper (either pdf or ps) along with the source files (images, tex files, etc). At my first attempt their automatic online pdf tool fail to work properly and the error was:

“We are sorry, but there is a problem with your submitted file(s) named ….pdf. Our system cannot process this file. The most common reason for this is badly embedded fonts or Type 3 fonts (which we do not support at the moment). If possible, please change the font settings and/or redistil this PDF to a lower Adobe Acrobat version and try again.

and by reading more (‘Read more’ link):

“A Type 3 font error is due to bit mapped fonts in your document or missing fonts used within the document. Bitmapped fonts display poorly on screen in PDF files and sometimes cause printing problems. We recommend for Word Documents that you embed your fonts and re-upload the file(s), or for PDF’s save them using Acrobat 6 (or lower).”

I tried their proposed solutions (adding the LaTeX packages: \usepackage[T1]{fontenc} and \usepackage{aecompl} , and trying also the \pdfminorversion=5) but nothing worked out. Then I tried to look around to see if there was any related post but nothing obvious (1; even though close). At some point, probably when I understood the context of the ‘Read more’, I uploaded the pdf file with text only and it worked! That means that there was a problem with font type of the images. I uploaded again the pdf file with only one image and the site refused to create the pdf file like before. I re-tried with an image that I hadn’t created myself and that one worked! So, definitely the problem was with my images, as produced through matplotlib.

At first I searched and asked various lists for an relatively easy way to the change the font type of the eps images by editing them somehow, without success (2 for example did not work, I didn’t try ps2ps/gs and psfrag, GIMP could also do it but the quality was lower). Since I was pressed by the deadline I decided not to look around for side-ways but proceed with brute force: re-create all plots! Although this didn’t involve any serious data processing (only to read some files), yet it was a serious amount of time since for many of plots I had to re-assign manually some plot parameters. Moreover, I had to find how to do it within matplotlib.

Thankfully, that was not that hard to perform. Following a similar post (3) I found the appropriate parameter inside the matplotlibrc for the postscript files: ps.fonttype
for which there are two options: “3” for Type3 fonts and “42” for TrueType. The default value is “3”, so by adding the line

from matplotlib import rcParams
rcParams['ps.fonttype'] = 42

in my scripts I could save the plots with the appropriate font type (I could of course change the default value but for some reason I thought not to do it know). All plots were done … all? except one, for which I did not understand why it kept been saved with type3 fonts – for that I used GIMP!

And finally … the paper was submitted!

References:
[1]: tex.stackexchange.com – How do I avoid Type3 fonts when submitting to ManuscriptCentral
[2]: osmanoglu.org – Embed fonts in EPS/PDF
[3]: stackoverflow.com – Cannot edit text in chart exported by Matplotlib and opened in Illustrator