# How can I substitute $s_x$ for Sin[x] in output to make an expression compact

I have a very cumbersome expression, which I need to export to TeX form. The equations ends up to be extremely long, so I prefer that mathematica can display $\rm{Sin}[\alpha_1]$ as $s_{\alpha_1}$ , etc., and $\rm{Sin}[\alpha_1+\alpha_2]$ by $s_{\alpha_1+\alpha_2}$. Preferably, this notation will not prevent the expression from further trigonometric simplification.

I can't find a way after a lot of search. Could someone help?

### Update

Thanks for the answers. They both work and have solved my problem, but I notice that they can no longer be further trigonometric simplified; for example,

 Simplify[
Sin[Subscript[α, 1]]^2 /. Sin[x_] :> Subscript[s, x] + Cos[Subscript[α, 1]]^2]


does not simplify to 1. I wonder if there is anyway that avoid this problem? If this is possible, then the outputs within Mathematica itself can be more compact, and can be used for further manipulation, which is helpful.

• Do you want to change the way it looks in TeXForm or in Mathematica, or both? Apr 21 '17 at 22:22
• MakeBoxes[Sin[x_], StandardForm] := MakeBoxes[Subscript["s",x], StandardForm] and something similar for Cos[x], although you might want to create a function to only produce the compact output when needed. Apr 21 '17 at 23:35
• @Carl Woll, this is exactly what I'm looking for, thanks a lot! Apr 21 '17 at 23:47

Also:

ClearAll[toSubscript]
toSubscript = Block[{Sin = Subscript[s, #] &, Cos = Subscript[c, #] &}, # ] &;

toSubscript[{Cos[Subscript[α, 1]] + Sin[Subscript[α, 1] + Subscript[α, 2]],
Cos[Subscript[β, 1]] +  Cos[Subscript[β, 2] Subscript[β, 3]]}]


• Your solution (as well as Josh Bishop's) seems to prevent further trigonometric simplifications. Apr 21 '17 at 23:08
• @Carl, good point. I assumed the expression to be re-formatted was already Simplifyed, or, if not, it can be used as toSubscript[FullSimplify[expr]]
– kglr
Apr 22 '17 at 0:08

One easy way to accomplish this goal is to use a simple replacement rule.

{Sin[Subscript[α, 1]], Sin[Subscript[α, 1] + Subscript[α, 2]]} /.
Sin[x_] :> Subscript[s, x]


In these cases I like to use $Preprint: $Preprint = # /. Sin[x_] -> Subscript[s, x] &


This does not alter the internal representation of the expressions, just the way they are displayed.