In retrospective, I think the most impactful decision I took when writing a new latex command for Maple 2021 was to not rely on `latex/foo` for displaying anything. Instead, rely on the Typesetting of it, which is "what you see displayed".
At the user level of latex, this is non-obvious; at the implementation level, for me at least, it was the only natural thing: we already have, in the Typesetting code, "how things should look"; coding that a second time as `latex/foo` didn't sound right. I made the same "wipe out" of redundant code years ago when removing `D/foo` routines from the library: nowadays, D uses the differentiation rules coded as `diff/foo`.
In both cases, `D/foo` and `latex/foo`, the old mechanism is still in place, but basically used nowhere in the Maple library.
So, besides the examples shown in ?latex,functions, if you want to see something closer to the actual implementation to write your own routines, say for Anticommutator, I suggest you input the expression, have it displayed in front of you, as it comes, or construct the way you want it displayed e.g. using the palettes, and recall that since Maple 2021 latex is based on what you are a looking at (the displayed expression) , then input:
Copy the output, paste, and you can do the experiments you feel appropriate to write your `latex/foo` routine as explained in ?latex,functions.
A question related to yours is: "How do you code `print/foo`?" Nowadays, that also takes advantage of Typesetting. For instance, input with(Physics), then
and you will see it using Typesetting structures. From `print/AntiCommutator` to a customized `latex/AntiCommutator` is two steps.
In fact, it suffices for you to write your `print/foo` to have that automatically taken into account by latex.
Now, the construction of Typesetting structures is not documented. But, you know, Maple is fantastic for its openness: for anything you find interestingly displayed, input lprint(Typesetting:-Typest(%)) followed by copy and paste on an input line for experimentation, and you will figure out rather quickly how Typesetting structures work.
Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft