Objectives and constraints
- Extracting all EPS images imported in the main input file without modifying the main input file heavily.
- Converting each of imported EPS images to PDF one and save it with its original file name.
Assumption
For the sake of best practice, I assume that you put all of your EPS images in a sub directory called Images
. It means that the directory structure is defined as follows.
other parents/project/Images/
other parents/project/main.tex
other parents/project/myextractor.sty
You have to follow this convention as the remaining code uses this structure. Of course you can change this directory structure but you also need to modify the code a bit (not much). main.tex
and myextractor.sty
will be discussed shortly.
You are using Windows. If you are non-Windows users, please disabled the cleaning code mentioned in myextractor.sty
.
You know that you must compile the main.tex
with
latex -shell-escape main
dvips main
ps2pdf -dAutoRotatePages#/None main.ps
Notes: For non-Windows users, replace #
with =
.
Step 1
Create a package called myextractor.sty
as follows. Save it as mentioned in the directory structure above.
% myextractor.sty
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{myextractor}[2013/10/09 v0.01 LaTeX package for my own purpose]
\RequirePackage{filecontents}
\begin{filecontents*}{template.tex}
\documentclass[preview,border=0pt,graphics]{standalone}
\usepackage{graphicx}
\graphicspath{{Images/}}
% Active the following code (between \makeatletter and \makeatother)
% if you want to cancel the effect of
% width, height and/or scale defined in \includegraphics
%\makeatletter
%\define@key{Gin}{width}{}
%\define@key{Gin}{scale}{}
%\define@key{Gin}{height}{}
%\makeatother
\let\ea\expandafter
\begin{document}
%\edef\z{\noexpand\includegraphics[\varone]{\vartwo}}\z
\ea\includegraphics\ea[\varone]{\vartwo}
\end{document}
\end{filecontents*}
\RequirePackage{graphicx}
\RequirePackage{pgffor}
\let\temp\includegraphics
\renewcommand\includegraphics[2][]{%
\temp[#1]{#2}%
\immediate\write18{latex -jobname=#2 -output-directory=Images \unexpanded{"\def\varone{#1} \def\vartwo{#2} \input{template}"} && cd Images && dvips #2 && ps2pdf -dAutoRotatePages=/None #2.ps}%
% disable the following if you are not Windows users.
\foreach \ext in {dvi, ps, log, aux}{\immediate\write18{cd Images && cmd /c del #2.\ext}}%
}
\endinput
Read the comments given in the code carefully. They are as follows.
% Active the following code (between \makeatletter and \makeatother)
% if you want to cancel the effect of
% width, height and/or scale defined in \includegraphics
%\makeatletter
%\define@key{Gin}{width}{}
%\define@key{Gin}{scale}{}
%\define@key{Gin}{height}{}
%\makeatother
and
% disable the following if you are not Windows users.
\foreach \ext in {dvi, ps, log, aux}{\immediate\write18{cd Images && cmd /c del #2.\ext}}%
Step 2
Modify your main.tex
as follows
% main.tex
\documentclass{book}
%\usepackage{graphicx}
\usepackage{myextractor}% automatically load graphicx
\graphicspath{{Images/}}
\begin{document}
\chapter{A}
\begin{figure}[hbtp]
\centering
\includegraphics[scale=.5]{A}
\caption{A}
\label{fig:A}
\end{figure}
A \ldots
\chapter{B}
\begin{figure}[hbtp]
\centering
\includegraphics[scale=.75]{B}
\caption{B}
\label{fig:B}
\end{figure}
B \ldots
\chapter{B}
\begin{figure}[hbtp]
\centering
\includegraphics[scale=1]{C}
\caption{C}
\label{fig:C}
\end{figure}
C \ldots
\end{document}
The important notes are
%\usepackage{graphicx}
\usepackage{myextractor}% automatically load graphicx
\graphicspath{{Images/}}
- Load
myextractor
package before graphicx
to prevent graphicx
overrides myextractor
definition. As myextractor
loads graphicx
internally, you actually can disable graphicx
in main.tex
.
\graphicspath
must be specified as given above.
Step 3
Compile main.tex
with latex-dvips-ps2pdf
explained above. Afterwards, check Images
folder, you will find a PDF version for each EPS image. Done!
I suspect the shadowing uses PDF features, which are not available in PostScript.
From the documentations, pgf-blur
:
This effect can be achieved in TikZ/PGF with the circular drop shadow
key,
And from the PGF manual:
In addition to the general shadow
option, there exist special options
like circular shadow
. These can only (sensibly) be used with a special
kind of path (for circular shadow
, a circle) and, thus, they are not
as general. The advantage is, however, that they are more visually
pleasing since these shadows blend smoothly with the background. Note
that these special shadows use fadings, which few printers will
support.
Export the image as PDF and pdfTeX can include it directly without the need to run a converter for the down-graded PostScript file (the conversion is actually done by ghostscript).
Best Answer
TeX Live 2010 and 2011 automatically convert EPS files to PDF, but it looks like it keeps converting, even when the EPS file hasn't changed. Working from Herbert's suggestion, this should do the trick. It may also work with other distributions, but I've not tried.