2

I have a series of eps picture to be included in a LaTeX document. They need to be stretched to fit the linewidth, without mantaining their ratio.

This solution works perfectly:

\resizebox{\linewidth}{\height}{\includegraphics{mypicture.eps}}

But in this case I get the text scaled too.

I am trying to make the scaling including the picture in TikZ, but I cannot find a way to tell TikZ to make an xscale=\textwidth/(the width of my picture).

Something like this:

\documentclass{article}
\usepackage{graphics}
\usepackage{tikz}
\begin{document}

\begin{tikzpicture}[xscale=\linewidth/\width,yscale=1]
\node at (0,0) {\includegraphics{esempio3024nuovo-1.eps}};
\end{tikzpicture}

\end{document}

Thank you for your suggestions, AM

  • If you mean text that is in the eps figure then tikz will scale it the same way as \resizebox (or you could just use \includegraphics options) If you want that text to behave differently you should look at psfrag – David Carlisle Nov 20 '14 at 8:27
  • I guess psfrag is the tool. I don't understand much from the manual, though. This tagging, I just need to import the file and resize without changing the font. I'll figure out. – user56153 Nov 20 '14 at 11:49
  • actually I don't understand your question at all to be honest, within the eps file (assuming the text really is fonts not just drawn paths) you have some lines and shapes and text, if you scale everything except the text where do you want the non-scaled text to go, all the coordinates of all the points have changed? – David Carlisle Nov 20 '14 at 12:03
  • To the proportionally scaled points. I just have to stretch the image a few millimeters to fill the line, otherwise I will have many images one on top of the other with different lenghts, and the right margin of the page would look bad. But if I alter the size of the font I will have many pictures (justidfied) with text of (very slightly) different sizes one close to the other. – user56153 Nov 20 '14 at 14:29
  • but depending on the image generation software each letter (or part of letter for accented letters) might be separately positioned by coordinate in the EPS, if you stretch them out while not changing their size it is going to look very odd. It may be that your EPS are in a very specific form and you can do this but clearly no tool is going to be applicable in general. why distort the image at all rather than just putting them into a table and aligning with white space as is more normal? – David Carlisle Nov 20 '14 at 14:37
1

Save the picture into a box and use \wd\IBox:

\documentclass{article}
\usepackage{graphicx}
\usepackage{tikz}
\newsavebox\IBox
\begin{document}

\sbox\IBox{\includegraphics{esempio3024nuovo-1.eps}}
\begin{tikzpicture}[xscale=\linewidth/\wd\IBox,yscale=1]
\node at (0,0) {\usebox\IBox};
\end{tikzpicture}

\end{document}

or

\node at (0,0) {\includegraphics{esempio3024nuovo-1.eps}};

if you do not want the saved Image

  • This method will resize the fonts as well, and it is actually the same method I have asked an alternative to in my question. In any case my picture doesn't even get resized. – user56153 Nov 20 '14 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.