I have some output from a CAS computation, in the form of a sequence of (sometimes gigantic) symbolic matrices. I simply want them displayed in a pdf (the CAS can output TeX), without having to coerce the individual matrices into the width of a preexisting document size.
Fitting each matrix into an equation environment and then decorating those with \resizebox{.9\hsize}{!} as suggested here works, but has undesirable results: the smaller matrices mushroom to gigantic font sizes, whereas the larger ones fit the page but are in tiny font.
What I'd rather do, if possible, is produce a document that automatically scales itself to the width of the widest equation. It was my understanding that the standalone document class is meant to achieve this (that was my reading of this post), but it doesn't do so for me.
In particular, the code
\documentclass[varwidth=true, border=0pt]{standalone}
\usepackage{amsmath}
\begin{document}
$
\left(\begin{array}{rrrr}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & \frac{t_{3} t_{5} - t_{3}}{t_{5}} - \frac{{\left(t_{3} t_{5} - t_{3} - \frac{{\left(t_{3} t_{5} - t_{3}\right)} {\left(t_{5} - 1\right)}}{t_{5}}\right)} {\left(t_{3} t_{5} - t_{5}\right)}}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{5}} & \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{5}^{2}} + \frac{1}{t_{5}} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{4} t_{5} - t_{4}\right)}}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{4} t_{5}^{2}} & -\frac{t_{3} t_{5} - t_{5}}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{4} t_{5}^{2}} \\
0 & \frac{t_{3} t_{5} - t_{3} - \frac{{\left(t_{3} t_{5} - t_{3}\right)} {\left(t_{5} - 1\right)}}{t_{5}}}{t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1} & -\frac{t_{5} - 1}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{5}} + \frac{t_{4} t_{5} - t_{4}}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{4} t_{5}} & \frac{1}{{\left(t_{3} t_{5} - \frac{{\left(t_{3} t_{5} - t_{5}\right)} {\left(t_{5} - 1\right)}}{t_{5}} - t_{5} + 1\right)} t_{4} t_{5}}
\end{array}\right)
$
\end{document}
(a snippet of my output) produces a cropped equation running off the right hand side of the pdf:
Edit:
After the helpful answers below I tried standalone on the full input available here. The result (with the maximum width, varwidth=16383.99999pt, as suggested in the comments) is
ERROR: Dimension too large.
--- TeX said ---
\height ->\ht \@tempboxa
l.2021 \end{document}
--- HELP ---
From the .log file...
I can't work with sizes bigger than about 19 feet.
Continue and I'll use the largest value I can.
Since this is a new issue though, I have accepted the answer below by @Schrödinger's cat as resolving the original matter.


varwidth=trueis removed, doesn't it? – frougon Mar 08 '20 at 01:57$$of\[\]or\begin{equation*}\end{equation*}tags, as is my intention. I have many of these matrices (the document is 30+pages long, all looking like that), and I want the widest one to set the width. – grobber Mar 08 '20 at 02:08\textwidthworth just isn't readable. – vonbrand Mar 14 '20 at 00:32