4

I would like to redefine the \div and \curl commands to give \mbfnabla\cdot and \mbfnabla\vectimes.

In unicode-math breaks \DeclareMathOperator we get the hint that we need to wrap redefines inside an AtBeginDocument block. While this seems to work for redefining \div with just giving the text div, using \nabla or \mbfnabla does not render the respective nabla symbol:

Maxwell equations with missing nabla symbols

The corresponding MVP code is:

\documentclass{scrartcl}

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

\newcommand{\vdot}{\cdot}
\newcommand{\vcross}{\vectimes}
\newcommand{\vb}[1]{\symbfup{#1}}
\newcommand{\vu}[1]{\hat{\vb{#1}}}

\AtBeginDocument{   
    \let\div\relax
    \let\curl\relax
    \DeclareMathOperator{\div}{\mbfnabla\vdot}
    \DeclareMathOperator{\curl}{\mbfnabla\vectimes}
}

\begin{document}
    \begin{align}
        \div\vb{E}
        &=
        j_0
        &
        \div\vb{B}
        &=
        0
        \\
        \curl\vb{E}
        &=
        -\partial_t\vb{B}
        &
        \curl\vb{B}
        &=
        \vb{j}
        +
        \partial_t\vb{E}
    \end{align}
\end{document}

I am using LuaLaTex on MacOS where I recently updated all packages with tlmgr update -all.

2
  • 1
    It’s a good practice to add \tracinglostchars=3 near the top of your document, which tells TeX to treat bugs like this as errors. Commented Oct 13, 2021 at 18:35
  • I just had this issue come up, where the font I used contained $\Delta$, but not $\nabla$. I ended up using $\sbox0{$\Delta$}\raisebox{\ht0}{\rotatebox{180}{$\Delta$}}$ as a replacement for $\nabla$. Commented Feb 29, 2024 at 18:46

1 Answer 1

5

The problem can be seen in the log file:

Missing character: There is no 𝛁 (U+1D6C1) in font [lmroman10-regular]

You can use a similar math font that has the glyph:

documentclass{scrartcl}

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

\setmathfont{NewCMMath-Regular.otf}

\newcommand{\vdot}{\cdot}
\newcommand{\vcross}{\vectimes}
\newcommand{\vb}[1]{\symbfup{#1}}
\newcommand{\vu}[1]{\hat{\vb{#1}}}

\AtBeginDocument{%
  \renewcommand{\div}{\mbfnabla\vdot}%
  \newcommand{\curl}{\mbfnabla\vectimes}%
}

\begin{document}

\begin{align}
  \div\vb{E}  &= j_0               & \div\vb{B}  &= 0
  \\
  \curl\vb{E} &= -\partial_t\vb{B} & \curl\vb{B} &= \vb{j} + \partial_t\vb{E}
\end{align}

\end{document}

enter image description here

You might use \DeclareMathOperator, but the spacing will be not the best.

\documentclass{scrartcl}

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

\setmathfont{NewCMMath-Regular.otf}

\newcommand{\vdot}{\cdot}
\newcommand{\vcross}{\vectimes}
\newcommand{\vb}[1]{\symbfup{#1}}
\newcommand{\vu}[1]{\hat{\vb{#1}}}

\AtBeginDocument{%
  \let\div\relax
  \DeclareMathOperator{\div}{\mathnormal{\mbfnabla\vdot}}%
  \DeclareMathOperator{\curl}{\mathnormal{\mbfnabla\vectimes}}%
}

\begin{document}

\begin{align}
  \div\vb{E}  &= j_0               & \div\vb{B}  &= 0
  \\
  \curl\vb{E} &= -\partial_t\vb{B} & \curl\vb{B} &= \vb{j} + \partial_t\vb{E}
\end{align}

\end{document}

enter image description here

But the definition can be, more simply,

\AtBeginDocument{%
  \renewcommand{\div}{\mathop{\mbfnabla\vdot}}%
  \newcommand{\curl}{\mathop{\mbfnabla\vectimes}}%
}
4
  • for some reason using setmathfont alone did not work for me but adapting renewcommand and newcommand did! Would you generally advise for newcommand over DeclareMathOperator? Commented Oct 13, 2021 at 13:47
  • @bodokaiser In this particular case, you don't want an operator, or, as I showed, the spacings are all wrong. Commented Oct 13, 2021 at 13:58
  • Ah, I think the term "operator" in DeclareMathOperator should not be understood in a strict "mathematical" sense, e.g., differential operator. In the amsmath package docs DeclareMathOperator is used for sin, lim, max, i.e., functions and operations which are abbreviated with letters (not a single symbol!). Commented Oct 13, 2021 at 14:04
  • 1
    @bodokaiser Yes, it's more in TeX sense, as regards to the spacing. Commented Oct 13, 2021 at 14:22

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.