1

As the title says I am trying to write a plus or minus as superscripts for various particle names in a bmatrix, but it does not work. I have searched for solutions, but only came up with one, which should work, but doesn't. Now it really bothers why LaTeX does not have this feature built in, that seems really silly, but maybe there is a good reason.

My code is:

%various packages
\newcommand{\minus}[1]{{#1}^{\scalebox{0.8}{-}}}
\newcommand{\plus}[1]{{#1}^{\scalebox{0.6}{\!+}}}
\begin{document}
\begin{bmatrix}
   \pi^{\plus} & 0 & 0 \\
   0 & 0 & 0 \\
   0 & 0 & 0
\end{bmatrix}
\end{document}

the error i get is "Argument of \plus has an extra }. \par \pi^{\plus} and the error repeats in my log - maybe 50 of the same errors but only on the same line.

Thank you for your time.

1
  • Welcome to TeX.SX! Macro \plus is defined having one argument, but it is used without argument. Likely, \plus{\pi} is the intended usage of the macro. Dec 16, 2016 at 3:02

1 Answer 1

3

You should define \plus and \minus to not take an argument:

enter image description here

\documentclass{article}

\usepackage{amsmath,graphicx}

\newcommand{\minus}{\scalebox{0.8}{$-$}}
\newcommand{\plus}{\scalebox{0.6}{$+$}}

\begin{document}

\[\begin{bmatrix}
  \pi^{\plus} & 0 & 0 \\
  0 & \pi^{\minus} & 0 \\
  0 & 0 & \pi^{\plus}
\end{bmatrix}\]

\end{document}

I've updated the definition slightly, ensuring that + and - are taken as math binary operators.

5
  • Thank you very much. That works and from your explanation i also see why. Simple and fast help, i appreciate it!
    – Yuki
    Dec 16, 2016 at 3:02
  • Does anyone know why this is not standard in LaTeX?
    – Yuki
    Dec 16, 2016 at 3:06
  • @Alex: What is this? \plus and \minus? It's because not everyone use it in your way.
    – Werner
    Dec 16, 2016 at 3:07
  • I understand that but i was thinking that a simple solution such as \+ would be useful to those who use it, without bothering those who do not use it. It works the same way with a lot of other special characters. Then again, that is just my opinion. Thank you once again for your help!
    – Yuki
    Dec 16, 2016 at 3:42
  • @Alex: For what it's worth, \- is an existing control sequence.
    – Werner
    Dec 16, 2016 at 3:48

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.