[Tex/LaTex] Making set length text box

boxes

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

Best Answer

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