6

I'm writing notes on vector calculus and have been using the \curl and \div operators from the physics package. Only after a while did I realise that \curl uses the bold-face version of \nabla rather than just \nabla.

Initially, I wanted to make all the bold-face nablas the same as the standard nablas, and managed to do that with this (from this post):

\DeclareDocumentCommand\vnabla{}{\nabla}

However, I think I actually like the bold-face version better and want to change all the existing nablas in the document to bold-face, preferably by redefining \nabla to produce the bold-face version (rather than manually searching for every single nabla in the document).

How would I do this? Sorry if this question is elementary. Any advice would be appreciated.

4
  • 1
    It's a bit confusing. Sounds like you had \nabla, then changed (some or all?) to \vnabla, but now want to change it back?
    – Werner
    Commented Nov 14, 2022 at 0:02
  • I'll be honest, I have no idea how that command works. All I know is that using that command, all the bold nablas in the \div and \curl commands turned into the standard \nabla. What I want now is for these to turn back (for which I can just get rid of that line in my preamble) and also for all the nablas (i.e., using only the \nabla command) in the document to become bold.
    – Trisztan
    Commented Nov 14, 2022 at 0:11
  • An aside. According to some conventions, bold-face would correspond to a vector or matrix, whereas regular face to a scalar... So might be necessary to change other symbols for consistency Commented Nov 14, 2022 at 11:59
  • @schrödingcöder Del is always a vector operator, so that's not a problem.
    – Trisztan
    Commented Nov 14, 2022 at 23:32

3 Answers 3

6

The \nabla command is defined as a character, using \mathchardef so to redefine it as a macro you need to create a new version of it that can be made bold in the same way that the physics package defines the \vnabla macro.

\documentclass{article}
\usepackage{physics}
\mathchardef\NABLA"272
\newcommand*{\Nabla}{\boldsymbol\NABLA}
\let\nabla\Nabla
\begin{document}
\[ \nabla(\frac{a}{b}) \]
\[ \grad(\frac{a}{b}) \]
\end{document}

output of code

8
  • I tried this and got the "TeX capacity exceeded" error. I was going to say that the problem might be that I used \grad as well, but then I noticed you did that too, so I'm not sure what its problem is. I don't think I can provide a MWE, since it seems to be a document-wide issue. For the time-being, I ended up just replacing every \nabla in the document with \grad using a text editor.
    – Trisztan
    Commented Nov 14, 2022 at 1:17
  • I'm confused by your comment. This is Alan Munn's solution isn't it?
    – Trisztan
    Commented Nov 14, 2022 at 1:21
  • I tried that, as well as replacing all the \grads with \nabla. One of my other packages probably doesn't like the change. Edit: Just saw you changed your comment. By 'that' I meant using \Nabla instead of \grad or \nabla.
    – Trisztan
    Commented Nov 14, 2022 at 1:26
  • 2
    @Trisztan Try to copy-paste only Alan's code in a brand new file. Commented Nov 14, 2022 at 1:27
  • 1
    Yeah, I did that, it works fine. Like I said, it only has problems in my particular document. Will probably just settle for my \grad solution.
    – Trisztan
    Commented Nov 14, 2022 at 1:28
5

You want to keep the standard \nabla somewhere and redefine the command, in order to avoid an infinite loop.

\documentclass{article}
\usepackage{amsmath,bm}

\AtBeginDocument{%
  \NewCommandCopy{\nablasymbol}{\nabla}%
  \DeclareRobustCommand{\nabla}{\bm{\nablasymbol}}%
}

\begin{document}

$\nabla$ (compare with $\nablasymbol$)

\end{document}

enter image description here

Note that you need to know nothing about how \nabla is defined to begin with. Also, \AtBeginDocument might be necessary if you use one of the math font packages that delay definitions at begin document; it doesn't harm doing it anyway.

If you're using unicode-math, the method is similar.

\documentclass{article}
\usepackage{amsmath}
\usepackage{unicode-math}

\AtBeginDocument{%
  \NewCommandCopy{\nablasymbol}{\nabla}%
  \DeclareRobustCommand{\nabla}{\symbf{\nablasymbol}}%
}

\begin{document}

$\nabla$ (compare with $\nablasymbol$)

\end{document}

Here \AtBeginDocument is certainly needed, because unicode-math does much of its job at that moment and we must delay the redefinition after that job.

0
2

If you are using Unicode math then all variants of nabla are ready in single font. Looking to unicode-math-table.tex we get:

\UnicodeMathSymbol{"02207}{\nabla          }{\mathalpha}{nabla, del, hamilton operator}%
\UnicodeMathSymbol{"1D6C1}{\mbfnabla       }{\mathalpha}{mathematical bold nabla}%
\UnicodeMathSymbol{"1D6FB}{\mitnabla       }{\mathalpha}{mathematical italic nabla}%
\UnicodeMathSymbol{"1D735}{\mbfitnabla     }{\mathalpha}{mathematical bold italic nabla}%
\UnicodeMathSymbol{"1D76F}{\mbfsansnabla   }{\mathalpha}{mathematical sans-serif bold nabla}%
\UnicodeMathSymbol{"1D7A9}{\mbfitsansnabla }{\mathalpha}{mathematical sans-serif bold italic nabla}%

So, if you want to use bold variant of nabla, you can set

\let\nabla=\mbfnabla

That is all. More things are simpler with Unicode math.

3
  • Might be a good idea to save the old definition by \let\oldnabla=\nabla or something similar so that it can be accessed if needed.
    – Aditya
    Commented Nov 14, 2022 at 6:33
  • @Aditya The solution here does not redefine \nabla at all. However, should you wish to, that is one thing that’s not simpler in unicode-math. The package defers defining most of its symbols until the end of the preamble, so you must wrap the redefinition in \AtBeginDocument{...}.
    – Davislor
    Commented Nov 14, 2022 at 7:58
  • 1
    @Davislor If you don't use LaTeX, then you don't have these problems with Unicode-math.
    – wipet
    Commented Nov 14, 2022 at 11:55

You must log in to answer this question.

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