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 have a document that should contain a bordered box with a paragraph of explanatory text. The box's width should be a percentage of that of the page's body.

I don't want to make the box a fixed width, because I will be making the document in two page sizes. I hope I'll only need to change the documentclass property, and to that end I hope it's possible to make the box width proportional to the page (or body) so that its width will make sense at both sizes.

I tried using \framebox but I don't seem to be understanding it properly -- I can't get the text in the framebox to wrap.

I suppose I could make a one-celled table, but it seems like I'm missing a more elegant solution.

share|improve this question

1 Answer 1

up vote 11 down vote accepted

You can use a minipage with the width as a proportion of textwidth.

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\fbox{\begin{minipage}{0.9\textwidth}
\lipsum[1]
\end{minipage}}
\end{document}

The \begin{minipage}...\end{minipage} puts a block of text in its own block. The 0.9\textwidth provides the sizing parameter.

To enclose everything in a frame you can use \fbox.

share|improve this answer
1  
Thank you, this worked perfectly! I'm afraid, though, that I don't understand why it works... I thought fbox was only for shorter pieces of text, all on the same line? –  HedgeMage May 6 '11 at 3:14
    
@HedgeMage I added a bit more notes. \fbox can take more than a line of text. Try adding two minipages without a line between them and at 0.47/textwidth. TeX grows on you it will take a bit of time and then everything clicks together. –  Yiannis Lazarides May 6 '11 at 3:41
    
Thanks for the added explanation, it really helped. –  HedgeMage May 6 '11 at 4:18
    
Yes, fbox takes text all on a same line. By putting text in a minipage you've in effect turned that paragraph into one big character. (Internally, TeX thinks characters are boxes, so that makes sense.) –  Victor Eijkhout Aug 11 at 14:42

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.