TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm writing a document including figures exported from Inkscape (in pdf+latex format). These figures use a figure environment containing all the text labels and a \includegraphics macro that imports the graphical part of the figure from the pdf file.

By default these figures use the same font as the rest of the document, which is too large for my needs. To work it around I have scaled the figure up, and then scaled it down to the original size using \resizebox. This doesn't alter the size of graphics, only the size of font used for rendering text labels, which is perfect.

However, there is one weird glitch that I can't get rid off. All figures are shifted to the right and are slightly smaller than figures included directly (that is, without wrapping with figure environment) in the \resizebox.

Below is a test document exposing this behavior:


  \caption{Test with ``figure'' environment.}

  \caption{Test without ``figure'' environment.}



A testfig.pdf_tex file exported from Inkscape (with comments removed):

    \errmessage{(Inkscape) Color is used for the text in Inkscape, but the package 'color.sty' is not loaded}
    \errmessage{(Inkscape) Transparency is used (non-zero) for the text in Inkscape, but the package 'transparent.sty' is not loaded}
    \put(0.51462818,0.17761502){\color[rgb]{0,0,0}\makebox(0,0)[b]{\smash{Some text}}}%

A screenshot showing the result.

share|improve this question
Welcome to TeX.sx! As new user without image posting privileges simply include the image as normal and remove the ! in front of it to turn it into a link. A moderator or another user with edit privileges can then reinsert the ! to turn it into an image again. – Martin Scharrer Jul 13 '11 at 13:47
Thanks, Martin. I've edited my question to add the link. – Andrzej Jul 13 '11 at 13:58
Unfortunately the \resizebox* seems to do the exact same thing as \resizebox, unless I'm missing something. Is there any documentation for this macro? The * makes searching for it difficult. – Andrzej Jul 13 '11 at 14:04
I was wrong about the \resizebox* here. This macro in its normal ans star form is described in the grfguide. – Martin Scharrer Jul 13 '11 at 14:16
up vote 3 down vote accepted

The problem is in the end-of-line characters after, for example, \providecommand\rotatebox[2]{#2}. When not used in \resizebox, these end-of-line characters are ignored because TeX is in vertical mode; inside \resizebox TeX is in horizontal mode and they count as spaces.

  \caption{Test with ``figure'' environment.}

Setting \endlinechar=-1 we are able to ignore them at least for the duration of the \input.

You may also define

  \endlinechar=-1 \input{#1}\endgroup}

and say

  \caption{Test with ``figure'' environment.}

You should check that the end-of-line is never used in the input file to separate words in the picture environment.

share|improve this answer
I just was going to post the same. :-) What do you think from \resizebox{\textwidth}{!}{\endlinechar=-1\relax\input{testfig.pdf_tex}} (in case he hasn't full control over the source; because of automatic generation). ` – Martin Scharrer Jul 13 '11 at 14:07
@Martin That's equivalent (or maybe better). It's the input file that's automatically generated, I believe. However I prefer using the new command, that can come handy also in other cases. – egreg Jul 13 '11 at 14:12
Thanks guys! All the advices are absolutely brilliant. – Andrzej Jul 13 '11 at 14:20
@Martin, what is the purpose of \relax? The document renders the same way without it. – Andrzej Jul 13 '11 at 14:20
@Andrzej: It's an endmarker (in this case), which tells LaTeX that the number -1 is finished. LaTeX otherwise would expand the next macro to see if there are more digits. In order to avoid this I use a \relax, however it might not always be necessary. – Martin Scharrer Jul 13 '11 at 14:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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