Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

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

2 Answers 2

up vote 5 down vote accepted

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

share|improve this answer

You could use bm (boldmath)

\documentclass{article}
\usepackage{bm}
\begin{document}
\( \bm{p_{1}}^2 \)
\end{document}
share|improve this answer
    
Hmm...then the p get kind of italized, cool. I have to think about this one for a minute. –  Love Learning Apr 29 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 at 14:40
    
Actually @erik, it is good that you did that, I might use it instead (or in the future). Thanks bro. –  Love Learning Apr 29 at 15:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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