LaTeX forum ⇒ Math & ScienceHow do you reliably bold math

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm

How do you reliably bold math

Postby Singularity » Sun Sep 27, 2015 5:40 pm

How do you bold math? I've been using \bm, but it doesn't work with \nicefrac (or any frac, I think), and now I find it also doesn't work with \sec, and there doesn't seem to be a workaround.

I've read suggestions to use \boldsymbol, but it seems to just be another name for \bm. The command \mathbf seems to have no effect whatsoever. Command \pmb makes it "super" bold, and a bit ugly (but that might have to do).

And none of these bold across an alignment character.

Command \boldmath kicks back the warning that it is not valid in math mode (which sounds like an oxymoron), making it difficult to use on the last line of an align statement. OTOH \mathbold doesn't cause any problems, or any bolding.

So how do you bold math? Especially math with \sec, \frac, \nicefrac in it at the end of a long \align statement, and maybe including the alignment character (unless that's a deal breaker).

I'd provide an MWE, but there is no one original copy. Instead, here are sample lines I would like to be able to bold.

  1. \documentclass[14pt,fleqn,reqno]{extarticle}
  2. \usepackage{amsfonts,amsmath,amssymb,amsthm}
  3. \usepackage{bm,nicefrac}
  4.  
  5.  
  6. \begin{document}
  7. Bold these lines
  8. \begin{align*}
  9. \vdots \\
  10. &\sec \left(\frac{\pi}{4}x\right) \\
  11. &\sec \left(\nicefrac{\pi x}{4}\right)
  12. \end{align*}
  13. \end{document}

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Mon Sep 28, 2015 7:28 pm

As I noted in my answer to your other answer: you can bold \nicefrac with \mathbf. Why not use that? You also found yourself the way to use \bm inside \nicefrac. Why not use that?

Just as a sidenote: bold letters in math usually have a distinct meaning from non-bold letters. $x$ usually is the variable x while $\bm{x}$ often denotes the vector x.

Regards
site moderator & package author

Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm

Postby Singularity » Tue Sep 29, 2015 1:51 am

The solution to using \bm inside of \nicefrac is time consuming. BTW, someone posted an even better answer somewhere (that I don't remember and can't find).

Also, \bm it doesn't work at all \sec and \csc and who knows what else.

I'm aware of the difference between, say $\bm{x}$ and $x$. But I'm writing lesson plans which I then deliver in front of the class. I don't want to sit reading it, looking for what I want. I want to bold specific parts so I can find them fast. And that includes the last line of lengthy problems.

I want something to quickly say "bold this whole line", and then move on to the next part of what I'm writing. The precise meaning of the bold is not as important. So far, I have found \pmb. "poor mans bold"?? maybe. That's what it seems like. But I wonder if there isn't a better solution.

User avatar
cgnieder
Site Moderator
Posts: 1990
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Tue Sep 29, 2015 10:04 am

Singularity wrote:Also, \bm it doesn't work at all \sec and \csc and who knows what else.


I don't understand what you mean here…
However, I did a little research and learned something new myself: the switches \boldmath/\unboldmath

  1. \documentclass{article}
  2. \usepackage{nicefrac,amsmath}
  3. \begin{document}
  4.  
  5. $ x^2 + y^2 - \sin z = 4$ \par
  6. $ \nicefrac{x_1}{2} + \nicefrac{x_2}{3} - \nicefrac{x_3}{6} = 5$
  7.  
  8. \boldmath
  9. $ x^2 + y^2 - \sin z = 4$ \par
  10. $ \nicefrac{x_1}{2} + \nicefrac{x_2}{3} - \nicefrac{x_3}{6} = 5$
  11. \unboldmath
  12.  
  13. \begin{align}
  14. x^2 + y^2 - \sin z &= 4 \\
  15. \nicefrac{x_1}{2} + \nicefrac{x_2}{3} - \nicefrac{x_3}{6} &= 5
  16. \end{align}
  17.  
  18. \boldmath
  19. \begin{align}
  20. x^2 + y^2 - \sin z &= 4 \\
  21. \nicefrac{x_1}{2} + \nicefrac{x_2}{3} - \nicefrac{x_3}{6} &= 5
  22. \end{align}
  23. \unboldmath
  24.  
  25. \end{document}


Regards
site moderator & package author

User avatar
Johannes_B
Site Moderator
Posts: 4140
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Tue Sep 29, 2015 3:20 pm

You want to make it bold to find it faster on the page. How about using a frame around the equation/math to stick out. Or a little square in the margin to catch your eye?


Poor mans bold: typesetting the same letter multiple times a bit shifted to the left and the right makes it look bold. But it isn't. It is just a hackish way to get ugly bold letters for people not able to afford a real bold font. That's what poor mans bold is.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

User avatar
Stefan Kottwitz
Site Admin
Posts: 9561
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Sep 29, 2015 6:37 pm

Generally, I think, the bm package is the best choice. I cite some features of it from my new LaTeX Cookbook:

  • Determining available bold math fonts and use them if available
  • Falling back to poor man's bold if no bold version can be found, which means overprinting with slight offsets
  • Keeping the correct spacing of the symbol
  • Respecting the meaning of symbols, such as delimiters

It just happens that \bm or others may have difficulties in making complex expressions bold. Fractions are non-trivial since they contain several parts.

Emphasizing a whole formula or section in bold is, in my opinion, not good anyway. Bold symbols usually transport a meaning. Like italic x as a variable, but bold x as a vector. It depends on the document and own style of course.

But when I think of bold symbols, I define them in a macro in the preamble. I don't use physical commands in a text. It could be very hard to change all the formatting later if a style should be changed.

So, my way with bm for a big bold X would be:

  1. \bmdefine{\bX}{X}


Later I use \bX in the text. In case I would decide to switch to medium-bold or heavy or even fancy calligraphic X, I just need to change the macro. No need to do for all occurrences in the text. And, the text has less braces and clearer names, if you would choose them.

Finally, compare bm and amsmath's \boldsymbol - also taken from an example in my book:

  1. \documentclass{article}
  2. \usepackage{bm}
  3. \bmdefine{\bX}{X}
  4. \bmdefine{\bi}{i}
  5. \bmdefine{\bMinus}{-}
  6. \bmdefine{\bSum}{\sum}
  7. \bmdefine{\bLeft}{(}
  8. \bmdefine{\bRight}{)}
  9. \begin{document}
  10. \[ \sum_{i} ( - X_{i} ) \]
  11. \[ \bSum_{\bi} \bLeft \bMinus \bX_{\bi} \bRight \]
  12. \end{document}


This bm example gives:

bm.png
bm.png (9.99 KiB) Viewed 43361 times


Now to amsmath:

  1. \documentclass{article}
  2. \usepackage{amsmath}
  3. \newcommand{\bX}{\boldsymbol{X}}
  4. \newcommand{\bi}{\boldsymbol{i}}
  5. \newcommand{\bMinus}{\boldsymbol{-}}
  6. \newcommand{\bSum}{\boldsymbol{\sum}}
  7. \newcommand{\bLeft}{\boldsymbol{(}}
  8. \newcommand{\bRight}{\boldsymbol{)}}
  9. \begin{document}
  10. \[ \sum_{i} ( - X_{i} ) \]
  11. \[ \bSum_{\bi} \bLeft \bMinus \bX_{\bi} \bRight \]
  12. \end{document}


That gives:

amsmath.png
amsmath.png (10.02 KiB) Viewed 43361 times


You can see the problems with amsmath \boldsymbol:

  • The summation symbol is not bold.
  • The summation index has moved.
  • The spacing between parenthesis and minus sign has become too wide.
  • The italic correction after the X is lost, the kerning is too high. That is, the index now is too far at the right.

Maybe this sample is not the fairest comparison, but I wanted to show points for bm.

Stefan
LaTeX.org admin


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 1 guest