As per the manual entry for LaTeXForm...
\ket{A??}{q??}::LaTeXForm("|", A??, "\rangle_{", q??, "}").
ex := \ket{n+1}{a};
gives me
| (n+1,a)
Also,
\GG{n??}::LaTeXForm("\stackrel{n??}{G}");
GGtst := \GG{1};
gives me  G with n?? on top, followed by (1) .
Removing the "??" in the definition of \GG just gives a popup generic Tex error saying that }\GG is not defined.