I want to save a tabularx using a savebox, such that I can define it in one place and print it in another. While the code below worked for a listing, I could not make it work for a table. Is there any way to achieve this? The code below gives me an "Not in outer par mode" error.
\documentclass{article}
\usepackage{tabularx}
\begin{document}
\newsavebox{\mybox}
\begin{lrbox}{\mybox}
\begin{table}
\begin{tabularx}{\textwidth}{|l|ll|}
x & y & z\\\hline
\end{tabularx}
\end{table}
\end{lrbox}
\usebox{\mybox}
\end{document}