I need a box with the following properties

  • framed
  • fixed width
  • content text is centered
  • manual line breaks in the content text are possible

The closest I have is:

\minibox[frame,c]{line 1\\longer line 2}

But I don't find a way to fix the width of the box. I want to set it to a fixed value, which is be wider than the automatic width.

2 Answers 2


You could create your own box:


  \fbox{% <- adds the frame
    \parbox{4cm}{% <- fixes the width
      \centering% <- centers the content

\foo{line 1\\longer line 2}

I would recommend you this answer:

Set the width of a fcolorbox

The idea is to create a command:

 {% #1 = width (optional)
  % #2 = inner alignment (optional)
  % #3 = frame color
  % #4 = background color
  % #5 = text

And then you can use it this way:

\framecolorbox[4cm]{blue}{blue!40}{what do I do here?}

Which would do:

enter image description here

Of course, if you want it to be a normal box without colors, you can just change the arguments

  • 1
    Thank you for the answer. But my impression is that I cannot do manual line breaks within the box.
    – azimut
    Jan 28, 2023 at 20:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .