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 want to put a long piece of text in a box, for example

The quick brown fox jumps right over the lazy dog. the quick brown fox 
jumps right over the lazy dog. the quick brown fox jumps right over the lazy 
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox 
jumps right over the lazy dog. the quick brown fox jumps right over the lazy 
dog. the quick brown fox jumps right over the lazy dog. the quick brown fox 
jumps right over the lazy dog.

How can this be done? Any suggestion in brief.

share|improve this question

5 Answers 5

You can use \fbox{...} to put a frame around a \parbox{...} containing your text. Here's an example document. Note the \noindent that prevents the box from being shifted to the right.

\documentclass{article}

\begin{document}

\noindent\fbox{%
    \parbox{\textwidth}{%
        The quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog. the quick brown fox jumps right over the lazy dog.
    }%
}
\end{document}
share|improve this answer

A minipage environment is a sufficient way to box or group something:

\documentclass{article}
\begin{document}
\begin{minipage}{15em}
  The quick brown fox jumps right over the lazy dog. the quick brown fox 
  jumps right over the lazy dog. the quick brown fox jumps right over the lazy 
  dog. the quick brown fox jumps right over the lazy dog. the quick brown fox 
  jumps right over the lazy dog. the quick brown fox jumps right over the lazy 
  dog. the quick brown fox jumps right over the lazy dog. the quick brown fox 
  jumps right over the lazy dog.
\end{minipage}
\end{document}

Minipage

If you want to frame it, you can put a \fbox command around it. That is,

\fbox{\begin{minipage}{15em}
...
\end{minipage}}

Minipage + fbox

share|improve this answer

enter image description here

\documentclass{article}
\usepackage{xcolor}
\usepackage{lipsum}
\begin{document}
\lipsum[1]

\medskip

\noindent\fcolorbox{red}{yellow}{%
    \minipage[t]{\dimexpr0.48\linewidth-2\fboxsep-2\fboxrule\relax}
        \lipsum[2]
    \endminipage}\hfill
    \fcolorbox{red}{yellow}{%
    \minipage[t]{\dimexpr0.48\linewidth-2\fboxsep-2\fboxrule\relax}
        \lipsum[3]
    \endminipage}

\medskip

\lipsum[4]
\end{document}

Notes:

  • You can adjust the thickness of border and padding of \fcolorbox{<border-color>}{<background-color>}{<contents>} by setting \fboxrule=<value><unit> and \fboxsep=<value><unit>, respectively. Put the setting before invoking \fcolorbox{<border-color>}{<background-color>}{<contents>}. For example: \fboxrule=1pt and \fboxsep=5pt.
  • Use t, c and b options to align the base line of the most top row, the center row and the most bottom row with the surrounding baseline.
share|improve this answer

The solutions with \fbox and minipage or \parbox all have the defect that the text will be an indivisible object which can't be split across pages. For a one shot application it might be the way to go. Otherwise there's the mdframed package that's highly customizable.

share|improve this answer

If you would like to specify the dimensions of the box (width and height) that is supposed to contain the text, please check this question: Fit text into given box by adjusting the fontsize

share|improve this answer

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.