1

I'm new to LaTeX, so please excuse me if this is something basic, but I've been reading the "Not So Short Introduction to LaTeX", and Googling this with no success.

I have larger chunks of text I want to draw a ruled box around. It could be anything from 1 sentence to a few paragraphs.

\framebox seems like it should do what I want, but everything ends up on one line, and I don't understand how to apply \raisebox to this problem, if in fact this is the correct solution.

(I'm using TeXShop 4.42 )

Any help appreciated.

  • There are many packages such as tcolorbox, mdframed and so on. True, they may be somewhat an overkill for just drawing a box, but they show what is possible. – Schrödinger's cat Oct 11 '19 at 3:45
  • Thank you @Schrödinger'scat Just started playing with tcolorbox and it's perfect. Does exactly what I want with minimum fuss. If you post as an answer, I can accept it as official. – nedlud Oct 11 '19 at 4:23
  • @nedlud When you accept a response, it does not make it an official response. It simply says that you think this answer is the best answer to your problem. tex.stackexchange.com/help/someone-answers – AndréC Oct 11 '19 at 5:46
  • \noindent\fbox{\parbox{\dimexpr \linewidth-2\fboxsep-2\fboxrule}{...}} will also work. – John Kormylo Oct 11 '19 at 14:26
  • Many of the boxes of this answer works enclosing a \parbox, as suggested, or a minipage, although for something more complex, just read the tcolorbox manual. – Fran Oct 13 '19 at 20:34
2

tcolorbox is a neat package for that.

\documentclass{report}
\usepackage[
showframe,%shows the page's frame
a6paper%suit to your needs
]{geometry}
\usepackage{lipsum}%arbitrary text
\usepackage{tcolorbox}

%https://osl.ugr.es/CTAN/macros/latex/contrib/tcolorbox/tcolorbox.pdf
\tcbuselibrary{breakable}
\tcbset{%any default parameters
  width=0.7\textwidth,
  halign=justify,
  center,
  breakable,
  colback=white    
}

\begin{document}

\vspace*{\fill} % for vertical centering 1/3

\begin{tcolorbox}
  \lipsum[1][1-2]%arbitrary paragrah
\end{tcolorbox}

\vspace*{\fill}% for vertical centering 2/3
% https://tex.stackexchange.com/a/511504/112708 % Why? Still unresolved
\vspace{\baselineskip}% for vertical centering 3/3

\newpage
\begin{tcolorbox}
  \lipsum[1] % text span multiple pages thanks to breakable
\end{tcolorbox}

\end{document}

Show

0

For simple types of boxes, please try with framed.sty or mdframed.sty packages, these are having many types of boxes, and the MWE is

\documentclass{book}
\usepackage{lipsum,framed}

\begin{document}

\begin{framed}
\lipsum[1-4]
\end{framed}

\end{document}

If you need boxes with complex design, then go with tcolorbox and tikz...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.