3

background

I want to show a multi-normal distribution, thus $x$ should be a vector. So I decide to use \bf or \mathbfto bold it on overleaf. However, when I bold my x, the \Sigma is undisplayed. I don't know why, maybe it is due to my loading packages or the example environment? I provide MWE below:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{ctex}
\usepackage[]{CJK}

\usepackage{amsthm}
\newtheoremstyle{break}
  {\topsep}{\topsep}%
  {\itshape}{}%
  {\bfseries}{}%
  {\newline}{}%
\theoremstyle{break}
\newtheorem{assumption}{Assumption}
\newtheorem{example}{Example}
\let\oldref\ref
\renewcommand{\ref}[1]{(\oldref{#1})}

\begin{document}

\begin{example}
\begin{equation}
\begin{aligned}
\log{\frac{g(\bf{x})}{f(\bf{x})}} =& \frac{1}{2}\log{\frac{|\Sigma_1|}{|\Sigma_2|}} + 
\frac{1}{2}(\mu_1^T \Sigma_1^{-1}\mu_1 - \mu_2^T \Sigma_2^{-1}\mu_2) \\
&+ (\mu_2^{T}\Sigma_2^{-1} - \mu_1^{T}\Sigma_1^{-1})\bf{x} +
\frac{1}{2}\bf{x}^{T}(\Sigma_1^{-1} - \Sigma_2^{-1})\bf{x}
\end{aligned}
\end{equation}
\end{example}

\end{document}


Which shows: enter image description here

If I do not \bf{x}, the code is like this:

\begin{example}
\begin{equation}
\begin{aligned}
\log{\frac{g(\bf{x})}{f(\bf{x})}} =& \frac{1}{2}\log{\frac{|\Sigma_1|}{|\Sigma_2|}} + 
\frac{1}{2}(\mu_1^T \Sigma_1^{-1}\mu_1 - \mu_2^T \Sigma_2^{-1}\mu_2) \\
&+ (\mu_2^{T}\Sigma_2^{-1} - \mu_1^{T}\Sigma_1^{-1})x + \frac{1}{2}x^{T}(\Sigma_1^{-1} - \Sigma_2^{-1})x
\end{aligned}
\end{equation}
\end{example}

Then, the display is right like this: enter image description here

  • 8
    \bf is very different from \mathbf (say) in that it does not take an argument. It is also wrong in an equation. So use \mathbf{x} or \boldsymbol{x} but not \bf. If you want to confine the effects of \bf to x, use {\bf x}, but, as I said, you should not use it at all. – Schrödinger's cat Jan 17 at 4:39
  • 4
    \let\oldref\ref \renewcommand{\ref}[1]{(\oldref{#1})} is another stunt that is really not to be used. There is the beautiful command \eqref for that, and clever users use the cleveref`` package with \cref`. – Schrödinger's cat Jan 17 at 4:42
  • @Schrödinger'scat Thank you so much! Change all \bf to \mathbf works very well. And your clever ref advise works too! – Travis Jan 17 at 4:47
  • \bf, along with most legacy two-letter font selection commands, has been deprecated for 25 years. Where did you find \bf{x} recommended to get a boldface letter in math? The bin is waiting for that guide. – egreg Jan 17 at 8:57
  • Not from document, my senior classmate told me to use \bf.... @egreg – Travis Jan 17 at 13:16
13

With the release of LaTeX2ε in June 1994,* the commands

\bf  \it  \sl  \rm

have been deprecated. The LaTeX kernel doesn't define them; however, document classes may define them (and indeed, the standard classes do, for backward compatibility reasons).

The fact that \bf seems to work in your document is not a reason for using it.

Besides, the pre-1994 older manuals told one to say {\bf x} in order to get a boldface letter in math. Newer manuals tell you to use \mathbf{x}.

If you do \usepackage{bm} (after loading amsmath), you have the alternative of using \bm{x} that you may like more for your vectors.

Never ever use \bf again and remove it from all your documents.


As far as your code is concerned, if I compile your code with TeX Live 2018, I get

enter image description here

The Sigmas you don't see are there, but they're boldface, which I don't think you want. There's much more unwanted boldface, too.

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[fontset=windows]{ctex}
\usepackage[]{CJK}

\usepackage{amsthm}
\newtheoremstyle{break}
  {\topsep}{\topsep}%
  {\itshape}{}%
  {\bfseries}{}%
  {\newline}{}%
\theoremstyle{break}
\newtheorem{assumption}{Assumption}
\newtheorem{example}{Example}
\let\oldref\ref
\renewcommand{\ref}[1]{(\oldref{#1})}

\begin{document}

\begin{example}
\begin{multline}
\log{\frac{g(\mathbf{x})}{f(\mathbf{x})}} = \frac{1}{2}\log{\frac{|\Sigma_1|}{|\Sigma_2|}} + 
\frac{1}{2}(\mu_1^T \Sigma_1^{-1}\mu_1 - \mu_2^T \Sigma_2^{-1}\mu_2) \\
+ (\mu_2^{T}\Sigma_2^{-1} - \mu_1^{T}\Sigma_1^{-1})\mathbf{x} +
\frac{1}{2}\mathbf{x}^{T}(\Sigma_1^{-1} - \Sigma_2^{-1})\mathbf{x}
\end{multline}
\end{example}

\end{document}

enter image description here


Footnote

* Yes, that's more than a quarter of a century, at the date of writing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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