alt-display does not play nicely with trace. The following output shows what happens when set_alt_display is used to replace the default 2d printer (an o in the output of trace represents a space).
$ maxima
Maxima branch_5_49_base_141_gd7e37bb4c https://maxima.sourceforge.io
using Lisp SBCL 2.6.0.debian
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) load("alt-display.mac");
(%o1) /usr/local/share/maxima/branch_5_49_base_141_gd7e37bb4c/share/contrib/al\
t-display/alt-display.mac
(%i2) set_alt_display(2,tex_display);
\mbox{\tt\red({\it \%o}_{2}) \black}$$\mathbf{done}$$
(%i3) f(x):=if x=1 then 1 else x*f(x-1);
\mbox{\tt\red({\it \%o}_{3}) \black}
\begin{verbatim}
f\left(x\right):=\mathbf{if}\;x=1\;\mathbf{then}\;1\;\mathbf{else}\;x\,f\left(x-1\right);
\end{verbatim}
(%i4) trace(f);
\mbox{\tt\red({\it \%o}_{4}) \black}$$\left[ f \right] $$
(%i5) f(5);
o oo ooo oooo oooo ooo oo o
\mbox{\tt\red({\it \%o}_{5}) \black}$$120$$
What is happening is that tex_display, in common with the other display functions defined using define_alt_display, checks if its input is a text form. If it is, alt_display_text is used to print the text form. Except, it assumes that the form looks like
((MTEXT . JUNK) "text to be printed")
Alas, trace's text forms look like
((MTEXT . JUNK) ((SPACEOUT N) ...)
The solution is to change alt_display_text to use the default printer, DISPLA, of these forms.
This is what the attached patch does.
The attached patch also works, too.
This is fixed in commit a0348f57.
With the patch: