I need to set the width of lrbox
to a particular size. I am trying with the following code:
\begin{lrbox}[width=.5\linewidth]
...
\end{lrbox}
However, it is throwing error. Any idea how can I set the width of lrbox? Thanks
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityWelcome! You can use e.g. \makebox
or \parbox
.
\documentclass{article}
\newsavebox\mybox
\begin{document}
\begin{lrbox}\mybox
\makebox[.5\linewidth][l]{pft}
\end{lrbox}
\usebox\mybox
\medskip
The width of the \texttt{lrbox} is \texttt{\the\wd\mybox}, and the line width is
\texttt{\the\linewidth}.
\bigskip
\begin{lrbox}\mybox
\parbox{.5\linewidth}{pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft pft}
\end{lrbox}
\usebox\mybox
\medskip
The width of the \texttt{lrbox} is \texttt{\the\wd\mybox}, and the line width is
\texttt{\the\linewidth}.
\end{document}
Further options include using a minipage
.
tcolorbox
. But of course this will no longer be an lrbox
/savebox
, which to the best of my knowledge do not support page breaks.