4

I have a repeated section of text that I'd like to use \savebox for. I discovered that \savebox has a limitation of one paragraph (see MWE below).

What are my best options for \savebox-like commands for more complicated bits of text? For example, multiple paragraphs, minipages, etc.

\documentclass[12pt,oneside]{article}
\begin{document}

{This is a paragraph.}

{This is another paragraph.}

\newsavebox{\temp}
\sbox{\temp}
{
{This is a paragraph.}

{This is another paragraph.}
}
\usebox{\temp}

\end{document}
6

\sbox accepts paragraphs in its argument but it is a horizontal box like \mbox so you need a nested \parbox.

\documentclass[12pt,oneside]{article}
\begin{document}

{This is a paragraph.}

{This is another paragraph.}

\newsavebox{\temp}
\sbox{\temp}{%
\parbox{\textwidth}{%
This is a paragraph.

This is another paragraph.
}}

\noindent\usebox{\temp}

\end{document}
0

In general, \long\def\something#1{#1} is close to your expectations, as you are expecting structures longer than one paragraph. Please remember however, that if an argument is too long, it may overfull the memory.

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.