Comment 49 for bug 380501

Revision history for this message
Bruno Grenet (bgrenet) wrote :

I read the whole discussion, and I am unable to decide whether we should strictly respect or not the EPS specifications. Nonetheless, I faced the problem of having my text and graphics unaligned while exporting to EPS+LaTeX. A solution is to export to PS+LaTeX or PDF+LaTeX but a publisher was asking for EPS only. Thus I used the following trick: I export to PS+LaTeX, use ps2eps to change my PS file to EPS, and change manually the BoundingBox according to the BoundingBox in the PS file. Note that as I need the PS file, it is quicker to only export in PS and then use ps2eps than exporting in both PS and EPS. Then I also have to change my .ps_tex file. This yields the following bash script. It is to be used after exporting file.svg to file.ps and file.ps_tex. It takes as only argument file.svg.

#! /bin/bash

file=${1%.svg}

ps2eps $file.ps

# Copy BoundingBox from ps to eps
# /!\ This does not respect EPS specifications, but this /seems/ to work with LaTeX

bb=$(grep "^%%BoundingBox:" $file.ps | cut -d: -f2 | cut -d" " -f2-)
bb1=$(echo $bb | cut -d" " -f1).000000
bb2=$(echo $bb | cut -d" " -f2).000000
bb3=$(echo $bb | cut -d" " -f3).000000
bb4=$(echo $bb | cut -d" " -f4).000000
sed -i -e "s/^%%BoundingBox: .*/%%BoundingBox: $bb/" -e "s/^%%HiResBoundingBox: .*/%%HiResBoundingBox: $bb1 $bb2 $bb3 $bb4/" $file.eps

# Change the file.ps_tex

mv $file.ps_tex $file.eps_tex
sed -i -e "s/\(\\includegraphics.*\){$file.ps}/\1{$file.eps}/" $file.eps_tex