Take the 2-minute tour ×
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.

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?

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
    
Great, exactly what I wanted. Thanks a lot! –  Pietair Jun 22 '13 at 13:45

Your Answer

 
discard

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.