# How can I add lists and similar in a savebox?

I'd like to have a savebox (or savebox-like functionality) that contains some 'simple' formatting, for example lists.

\documentclass{article}
\begin{document}
This is a sentence
\begin{itemize}
\item I am a list
\end{itemize}
\end{document}


However my experimenting with \savebox, \sbox, \begin{savebox} and the like are failing me. I also tried to define a minipage inside the savebox, but either that doesn't work or I don't know the syntax.

-
Welcome to TeX.SX! \newcommand{\reptext}{This ...} and then \reptext when you need it. –  egreg Apr 3 at 12:23

For this type of material you can just save your text etc. in a macro

\documentclass{article}

\begin{document}

\newcommand{\mytext}{This is a sentence
\begin{itemize}
\item I am a list
\end{itemize}}

\mytext

Something else.

\mytext

\end{document}

-

While Andrew's solution works great in many, many situations, it will fail in some, for example, if you try to place \mytext in an \fbox. To get around that problem, you really have to define \mytext to place the contents in a box.

\documentclass{article}
\parindent 0in
\begin{document}

\newcommand{\mytext}{\setbox0=\vbox{%
This is a sentence
\begin{itemize}
\item I am a list
\end{itemize}%
}\box0}

\mytext

Something else.

{\hfill\makebox[0pt]{\fbox{\mytext}}\hfill}

\noindent\rule{\textwidth}{1pt}

\end{document}


-
Do you think that \fbox{\begin{itemize}...\end{itemize}} is legal? I bet you don't. So what? Of course you get an overfull message with your code and adding \noindent won't help. –  egreg Apr 3 at 13:42
@egreg I was just trying to make the more general point that there are some things that actually have to get stuffed into a box if you are going to later manipulate them. Perhaps this was not the best example on which to make that point. –  Steven B. Segletes Apr 3 at 15:58
@egreg Revised my MWE to better make the point. –  Steven B. Segletes Apr 3 at 16:04