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.

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

1 Answer 1


Does this do what you need?

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

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

  • $\begingroup$ Would the x be integrated if I did Integral(k_1x) here? $\endgroup$ Commented Sep 24, 2016 at 21:29
  • $\begingroup$ @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? $\endgroup$
    – Alan
    Commented Sep 25, 2016 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.