Thanks to Bruno for suggesting that for my specific case, where my results come from Mathematica, it's simply much easier to change the output in there using trivial replacement rules. However, this stands alone as a general question.
This is a slightly different question to what I've seen before, where I can use something like \newcommand{\ga}{\gamma} to make shortcuts of things using \.
I have a series of LONG equations with stuff like x[2] or a[3] in them. I want to be able to always replace any instance of them with something else, like a command that takes a string and replaces it like something similar to
\newcommand{x[2]}{x_2}
and
\newcommand{a[2]}{\beta}
Ideally, this would take account of the number inside, but I could easily just do it for all instances that arise. Any guidance would be great (my document class is Report)





x[2]for example, where I avoided subscripts in my code. I now want to save myself effort and simply definex[2] = x_2in Latex, since it'll only ever occur within an equation. – Brad Mar 26 '19 at 15:50a[1]in Mathematica, I really want\alpha. I'm hoping I can find a simple macro to redefine every instance like this. Although thank you for pointing that output, that's actually very useful! – Brad Mar 26 '19 at 15:53x\[([0-9])\]and replace withx_$1(on a copy of course) – Chris H Mar 26 '19 at 15:54