6

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?

2
  • I think you should change the title of this question to something more relevant. The question doesn't mention the \tensor command anywhere. Apr 29, 2014 at 14:27
  • It did, it just wasn't highlighted, it is fixed now. But I agree, the title sucks. Apr 29, 2014 at 14:31

2 Answers 2

6

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

5

You could use bm (boldmath)

\documentclass{article}
\usepackage{bm}
\begin{document}
\( \bm{p_{1}}^2 \)
\end{document}
3
  • Hmm...then the p get kind of italized, cool. I have to think about this one for a minute. Apr 29, 2014 at 14:35
  • Yeah. Not sure if that's what you're looking for, but I thought I'd throw it out there anyway. You could also incorporate this into the solution provided by @egreg, i.e., defining a new command.
    – erik
    Apr 29, 2014 at 14:40
  • Actually @erik, it is good that you did that, I might use it instead (or in the future). Thanks bro. Apr 29, 2014 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .