15

I would like to wrap the text inside a \framebox, such that it continues on the next line instead of running out of the margins.

A minimum working example:

\documentclass[]{report}
\begin{document}

\framebox{\textit{If this script fails, you can try the following: 
  lower the degree (d), decrease the number of simplices, increase 
 the order of continuity (if possible) or increase the number of 
 datapoints in the listed simplices}}.

\end{document}

Any ideas?

1 Answer 1

17

Set the contents of the \framebox in a \parbox:

enter image description here

\documentclass{article}
\begin{document}

\noindent
\framebox{\parbox{\dimexpr\linewidth-2\fboxsep-2\fboxrule}{\itshape%
  If this script fails, you can try the following: lower the degree~(d), 
  decrease the number of simplices, increase the order of continuity (if possible) 
  or increase the number of datapoints in the listed simplices.}}

\end{document}

The calculations (using \dimexpr) ensures that the width of the box excludes the gap between the contents and the frame (2 gaps of \fboxsep and 2 widths of \fboxrule on either side). Also, since you're probably not interested in a paragraph indent outside this block, I've used \noindent.

Note that this block is not breakable across the page boundary.

1
  • Great, exactly what I wanted. Thanks a lot!
    – Pietair
    Jun 22, 2013 at 13:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .