I'm using the adjust package to add the frame option in \includegraphics command. The package is loaded in this way:


Now I can write the following command:

\includegraphics[width=\textwidth, frame]{foo.png}

and borders will be automagically added to the image.

Unfortunately using this options I get the well-known overfull \hbox (.. too wide) in paragraph warning. Without the frame option the warning disappears.

Does exixst a way to defeat this warning using the frame option?

  • 1
    Is the width of your image set to \textwidth or \linewidth? The width of the frame comes in addition to that. – Torbjørn T. Sep 15 '13 at 15:49
  • @TorbjørnT. It's set to \textwidth – eang Sep 15 '13 at 16:03
  • related : tex.stackexchange.com/q/20640/138900 – AndréC Dec 10 '19 at 9:05

Here's how you can do; which one to choose between the second and third example is a matter of taste and of what your pictures contain.

The frame option draws a frame with rule of width \fboxrule (by default) and zero space between the frame and the box. But the rule width is added to the width of the box, so you have to do something about it: either reduce a bit the width of the box, or draw the frame inside the box, by specifying a negative separation (second parameter to the frame option).

\setlength{\parindent}{0pt} % just for the example



% first example: bad, there's an overfull of twice the rule width    


% second example: good, the frame is drawn outside the picture


% third example: good, the frame is drawn inside the picture
\verb|\includegraphics[width=\textwidth,frame={\fboxrule} {-\fboxrule}]{tiger}|\\
\includegraphics[width=\textwidth,frame={\fboxrule} {-\fboxrule}]{tiger}

Don't include the minipage environments, they are just to show the effect while using \textwidth (that's reset in a minipage) and not having a huge picture of the result.

enter image description here

Defining a command for this kind of job is quite easy:


so you can call



\twincludegraphics[<other options>]{tiger}

where <other options> might even countermand the default ones for special cases.

| improve this answer | |
  • This is very fine. Does exist a way to wrap this options in a \newcommand ? (since I need to use them very often) – eang Sep 15 '13 at 16:50
  • 1
    @ital I added the new command based on the second scheme; it will be easy to change if you prefer the third one. – egreg Sep 15 '13 at 18:16

You don't say what you want to happen, without adjustbox then


will make a frame that overprints the edge of the image, so the resulting combination is still just \textwidth wide and will fit on the page


will make a border around the outside of the image so the resulting combination is too wide by the width of the padding and border on each side, so you need


So the resulting combination is \textwidth wide.

Or perhaps you want the image full width and the frame in the margin

| improve this answer | |
  • I want the image to be \textwidth wide – eang Sep 15 '13 at 16:05
  • @ital so do you want the frame over-printing the image, or sticking in the margin? If the image is already full width there is no space for the frame down the sides – David Carlisle Sep 15 '13 at 16:09
  • 1
    adjustbox sets fboxsep to zero when frame is applied I think, so you only need \includegraphics[frame,width=\dimexpr\textwidth-2\fboxrule\relax]{...}. – Torbjørn T. Sep 15 '13 at 16:10
  • @DavidCarlisle I think that I can deal with the frame over-printing the image – eang Sep 15 '13 at 16:19

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.