1

Is it possible to line-break a framed text box in LaTeX? If so, is it necessary to use some package to do so, and what is the name of that package?

EDIT: For greater clarity, let me give an example. Suppose I am typing a line of text and I put a long word in a framed box at the end of this line. Because by default LaTeX will not line-break such a framed box it will stick out of the right margin of text. My question concerns the possibility of line-breaking this framed text box over to the left side of the next line. In this way, both the text and the frame itself would be line-breaked from the right side of the given line to the left side of the next line.

  • 1
    No, you do not need a package, e.g. \documentclass{article} \begin{document} \fbox{\begin{minipage}{3cm} This is a rather long sentence with no meaning. \end{minipage}} \end{document} works, but you may enjoy the nice options tcolorbox offers. – Schrödinger's cat Nov 4 '19 at 3:58
  • Perhaps I'm not being clear: I want the frame itself to break over a line. – The Riddler Nov 4 '19 at 4:00
  • Sorry, can you try to rephrase? Or are you looking for tex.stackexchange.com/q/411339 ? – Schrödinger's cat Nov 4 '19 at 4:01
  • I think that's what I'm looking for, although it looks awfully complicated :( – The Riddler Nov 4 '19 at 4:08
  • Can you post MWE? and also provide more clear picture on your requirement.. – MadyYuvi Nov 4 '19 at 5:11
3

I know only a trick, which works only manually:

\documentclass[12pt,a5paper]{article}
\usepackage{fbox}
\begin{document}

We look inside the alternate reality of the president’s 
Twitter account, where he absorbs and amplifies a 
noxious stream of disinformation.

We look inside the alternate reality of the \fbox[lbt]{presi-} \fbox[rbt]{dent’s} 
Twitter account, where he absorbs and amplifies a 
noxious stream of disinformation.

\end{document}

enter image description here

|improve this answer|||||
  • Where can I find documentation on the optional [lbt] and [rbt] arguments to the \fbox command? – The Riddler Nov 4 '19 at 13:15
  • I suppose in the documentation of the package ... ;-) – user187802 Nov 4 '19 at 13:18
  • Ah, didn't realize fbox was also a package since one can use the \fbox command without loading any packages. Thanks. – The Riddler Nov 4 '19 at 13:19
0

Easy way to create a framed box is:

\usepackage{framed}
\begin{framed}
blah blah...
\end{framed}

This allows line break, page break etc.

Framed boxes with many custom styles then tcolorbox and tikz packages are preferable.

mdframed package also one of nice package which supports framed box with breaking option...

|improve this answer|||||

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.