[Tex/LaTex] Is it wise to use \tensor for bold letters

boldpackagessubscriptssuperscriptstensor

I want to use bold math-letters e.g.
\mathbf{p_1}^2. The problem with \mathbf{p_1}^2 is that the 1 and 2 sub/superscripts are not aligned under each other. I can fix this by writing
\mathbf{p_1^2} but then both the sub and superscript appears bold, I only want one of them bold (the 1 in the subscript). So what is the best solution to this? Is it wise to use the \tensor package to do this (if possible), what if one has thousands of these in a book/article, wouldn't calling the tensor package for each of them make compiling extremely slow?

Best Answer

This should be sufficiently clean; the bold subscript is not really a subscript, but part of the name, so it's treated as an optional argument.

\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand{\tens}{mo}
 {% #1 = variable name, #2 = subscript (optional)
  \mathbf{#1}\IfValueT{#2}{_\mathbf{#2}}%
 }

\begin{document}
$\tens{p}[1]^{2}$ and $\tens{p}^{2}$
\end{document}

enter image description here