0

LaTex noob here. Im looking for a simple way to make a box in latex that won't expand to fit the text. I have been trying to use a minipage within a fbox but it keeps expanding. I have been trying to make a 3in by 5in box

  • 2
    should it break the text? – percusse Mar 7 '16 at 0:17
  • I looking for it so when it reaches the end of the box, it would start a new line, so i believe so. – Alex Mar 7 '16 at 0:30
  • Parbox has three optional parameters the first [t,b,c] locates the baseline, the second specifies the height, and the third [t,b,c,s] locates the text inside the box. [s] stands for span which basically stretches the text to fill the box (requires at least something inside which stretches). – John Kormylo Mar 7 '16 at 2:21
1

The following code uses the fitting library of the tcolorbox package to create a 3in by 5in box with never expands this size. The text content is rescaled to fit into this box.

\documentclass[12pt]{article}

\usepackage[fitting]{tcolorbox}
\usepackage{lipsum}

\newtcboxfit{\mybox}[1][]{%
  fit algorithm=hybrid*,
  width=3in,
  height=5in,
  sharp corners,
  colframe=black,colback=white,
  size=fbox,#1
}

\begin{document}

\mybox{Testbox}

\mybox{Testbox with some more text, more text, more text, more text, more text.}

\mybox{\lipsum[1]}

\mybox{\lipsum[1-2]}

\mybox{\lipsum[1-3]}

\mybox{\lipsum[1-4]}

\end{document}

This output for the last four boxes is:

enter image description here

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.