1

I would like to change the meaning of @ in math mode to be such that it takes the object following it and makes it bold, e.g. $@x$ should produce a bold math x, $@\alpha$ should produce a bold alpha, and $@{\hat x^2}$ should make everything inside the curlies bold.

The following code doesn't work; I'm out of my depth.

\documentclass{article}

\usepackage{amsmath}
\usepackage{bm}


\begingroup
\lccode`\~=`@
\lowercase{\endgroup
\def~#1~{\boldsymbol{#1}}%
}%
\mathcode`@="8000



\begin{document}
$@x$   % I want this to produce a boldface math x
\end{document}
  • 1
    \def~#1{\bm{#1}} – egreg Aug 18 '16 at 19:24
  • Add an answer and I'll $\checkmark$ it. – JPi Aug 18 '16 at 19:27
4

The syntax you're defining is $@x@. If you just want @, it should be

\begingroup\lccode`\~=`@ \lowercase{\endgroup\def~#1}{\bm{#1}}
\mathcode`@="8000

Complete example

\documentclass{article}

\usepackage{amsmath}
\usepackage{bm}

\begingroup\lccode`\~=`@ \lowercase{\endgroup\def~#1}{\bm{#1}}
\mathcode`@="8000

\begin{document}

$x+@x$

\end{document}

enter image description here

  • 1
    Enter image description here...? – daleif Aug 18 '16 at 19:33
  • 5
    @daleif egreg is new here, he hasn't quite mastered the site format. – David Carlisle Aug 18 '16 at 19:41

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.