I'm trying to scale some text up. It seems like \resizebox
(from graphicx
?) and \adjustbox
(from the adjustbox
package) ignore line breaks:
\resizebox{5cm}{!}{Hello\\
world}
Is there a way to scale things up that respects line breaks?
line-breakingscaling
I'm trying to scale some text up. It seems like \resizebox
(from graphicx
?) and \adjustbox
(from the adjustbox
package) ignore line breaks:
\resizebox{5cm}{!}{Hello\\
world}
Is there a way to scale things up that respects line breaks?
Best Answer
Both use a horizontal savebox to store and then scale the content. You can't have line breaks in this kind of boxes. While manual line breaks would be somehow possible (e.g. using some vertical stacked
\hbox
es), automatic line breaking only works when a specific width is given.The
adjustbox
package supports aminipage=<length>
key which automatically places aminipage
around the content. Then line breaks will work.It also has a
tabular
key, which also allows the stacking of lines, e.g. usingtabular=@{}l@{}
to left-align all lines without any separation on the right and left of the table. So your example could now be written as\adjustbox{tabular=@{}l@{},width=5cm}{Hello\\world\\}
. Note that the trailing\\
is mandatory whentabular
is used.You can also use
\shortstack{Hello\\world}
(maybe with\strut
s included) to get the line breaking. Then there is theminibox
package which provides a quicktabular
as macro\minibox
.