# Making subscripts with variable

How do I make a variable $k_{1x}$ where the $x$ is just a label to denote the magnitude along the x-axis and not an actual defined variable x in the code?

Similarly, if I wanted to make $E_x$ or $E_{0x}$ for electric field notations, not only can I not use a variable subscript, the $E$ is replaced by Exp.

• E is a built-in function. You should not use symbol names that start with capital letter to avoid conflicts with build-in functions. – Edmund Sep 24 '16 at 16:42
• Ok even if I use q_x, how do I do that? – Nisha Mariam Johnson Sep 24 '16 at 16:47
• Use Indexed for subscripted variables. – QuantumDot Sep 24 '16 at 18:21

Does this do what you need?

ClearAll[kx, k, x]
Format[kx[n_]] := Subscript[k, n, x]
kx[1]
kx[1] = 5
kx[1]


If for some reason you actually need variables with subscripts, see How to create symbol whose name has subscript?

• Would the x be integrated if I did Integral(k_1x) here? – Nisha Mariam Johnson Sep 24 '16 at 21:29
• @NishaMariamJohnson I'm confused. In your qeustion, you said you wanted x as a label, not as a variable. Are you now saying you want it to be a (bound) variable in an integrand? – Alan Sep 25 '16 at 1:12