I'm trying to write some $\TeX$ conversion for a tensor with an upper and a lower index, but I would like the lower index to be displaced to the right by the width of the upper index. In (La)TeX I would write this as W^I_{\hphantom{I} J} ($W^I_{\hphantom{I} J}$). I tried to use the Invisible Mathematica command, which seems to be the counterpart of $\TeX$'s \phantom, but instead of getting a space I get the upper index repeated as a lower index.
Here's the code I'm using now, which doesn't quite work:
w /: MakeBoxes[w[i_,j_],fmt_:StandardForm] := (*BUGGY*)
SubsuperscriptBox[MakeBoxes[W,fmt], RowBox[{MakeBoxes[Invisible[i],fmt], MakeBoxes[j,fmt]}], MakeBoxes[i,fmt]]
This does work in the notebook front-end, but not when converting to (La)TeX. What is the best way to achieve the result I'm after?


ConversionRulesin the site, and check out if you can add your own rules to export some invisible box into a \hphantom. I haven't usedConversionRulesyet – Rojo Jun 09 '12 at 16:07ConversionRulesis what is needed here since they just tell Mathematica how to export a styled cell to say TeX or HTML. I was having a similar problem in which mma didn't give me the correct TeX transformation. I think this is all done withConvertTeXBoxesToTeXbut I have no idea what this function wants so that we can get an\hphantomout of it. – jmlopez Jun 09 '12 at 19:33W^I{}_Jis different from the indicated construction with\hphantomin that the subscript of the former is displaced too far horizontally. – murray Jun 09 '12 at 20:27"BoxRules"but I still can't make it work correctly. Not sure if I should make it another question, but Sidious Lord question has gotten me to think more about how to write proper rules to convert from mms to tex. Consider the following:RawBoxes@ConvertTeXTeXToBoxes[ "\\int_{a\\hphantom{b} c}^{\\hphantom{a} b\\hphantom{c} d}"]. How would you make it write it correctly in mma? You know what, I am making it another question. – jmlopez Jun 09 '12 at 21:36Invisiblesets an optionShowContents -> Falseand then you use"BoxRules"to search for it and replace it with\hphantom. – Sidious Lord Jun 10 '12 at 07:05