5

I have a box that's the full width of the page. I would like to offset it back into the margin a little, but when I do that it no longer reaches the edge of the page. Is it possible to keep using a macro like \textwidth but add a constant value onto it?

\hspace{-5mm} % Go back into the margin a bit
\colorbox[gray]{0.85}{
  \parbox{\textwidth}{  % Need \textwidth + 5mm to end up in the same place
    Hello
  }
}
8

add

  \usepackage{calc}

then you can go

  \parbox[t]{\textwidth + 5mm}
  • Works great and very clean syntax - thanks! – Malvineous Jul 20 '12 at 6:08
5

With a current pdftex you can do

\parbox{\dimexpr\textwidth+5mm\relax}{...}

\parbox doesn't know the [l] option you used.

  • That works nicely if the calc package is unavailable, thanks. I'm not sure where the [l] came from in that case but you're right, it shouldn't be there. – Malvineous Jul 20 '12 at 6:07

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.