How to put a long part of text in a box in LaTeX?
In this tutorial, you will learn how to put a long part of text in a box in LaTeX.
You can use the \parbox{<width>}{<text>}
command to put some text into a box of any width, then you can use the \fbox{}
command to get a frame around the text, like this.
\fbox{\parbox{<width>}{<text>}}
\documentclass{article} \usepackage{lipsum} \begin{document} \noindent\fbox{\parbox{10cm}{\lipsum[1]}} \noindent\fbox{\parbox{3in}{\lipsum[1]}} \noindent\fbox{\parbox{\textwidth}{\lipsum[1]}} \end{document}
Output:
Put a long part of text in a box with minipage
You can also use the minipage
environment to put some text into a box. Like this.
\documentclass{article} \usepackage{lipsum} \begin{document} \fbox{ \begin{minipage}{\linewidth} \lipsum[1] \end{minipage} } \begin{minipage}{\textwidth} \fbox{ \begin{minipage}{0.5\linewidth} \lipsum[1][1-6] \end{minipage} } \fbox{ \begin{minipage}{0.5\linewidth} \lipsum[1][1-6] \end{minipage} } \end{minipage} \end{document}
Output:
Leave a Reply