[Tex/LaTex] Consistent font size in EPS image that are scaled

diagramsepsfontsizescaling

Assume that at creation time (of an EPS image) the final 'size' of the image is not known. However, this one EPS is used multiple times in different sizes within different documents.
But the font size of text (e.g., axes labels) should be consistent.

Example: In one .tex use

\includegraphics[width=0.5\textwidth]{my_plotted_function.eps}

and in another use

\includegraphics[width=0.3\textwidth]{my_plotted_function.eps}

but ensure, that the axes labels are shown with 12pt in both figures.

Is there another way/vector graphics format to reach this functionality? (pstricks, tikz is not a solution, since it's not a supported export format.)

Best Answer

psfrag allows for this by default since it inserts the <replacement> of <tag> at compile-time:

\psfrag{<tag>}{<replacement>}

So you have to create the document with appropriate tags that can be replaced within your document. Here is a minimal example, taken from the auto-pst-pdf package on CTAN. The example image is example.eps:

psfrag maintains consistent font size when image is scaled

\documentclass{article}
\usepackage{graphicx}% http://ctan.org/pkg/graphicx
\usepackage{psfrag}% http://ctan.org/pkg/psfrag
\begin{document}

% psfrag setup
\psfrag{[Mp]}{$M_p$}%
\psfrag{[hb]}{$\mathbf h$}%
\psfrag{[epb]}{$\mathbf{e}_p(n)$}%
\psfrag{[evh]}{$\hat{e}_v(n)$}%
\psfrag{[epsv]}{$\varepsilon_v(n)$}%
\psfrag{[ev]}{$e_v(n)$}% 

Original image: \par
\includegraphics{example} \par\bigskip\bigskip%

Scaled 50\%: \par
\includegraphics[scale=.5]{example} \par\bigskip\bigskip

Scaled 150\%: \par
\includegraphics[scale=1.5]{example}
\end{document}​

It is obvious that the <replacement> text maintains a consistent font size, based on the document default. You may have to adjust the placement of the <replacement> based on the image size.