1

I'm writing a document with a lot of Greek letter combinations like $2x^2$. I'm tired of having to type \gamma^{\mu} or similar every time. I wanted to define a macro which would produce the same result. If I wanted the superscript to be bold, I would use:

\newcommand{g}[1]{\gamma^{\textbf{#1}}}

which produces enter image description here . Obviously, I want the superscript to be a Greek letter, however:

\newcommand{g}[1]{\gamma^{\#1}}

doesn't work. What's the correct syntax?

  • Welcome to TeX.SE. \textbf is for text mode ;-) You want, if at all, \mathbf{\mu} And Using \newcommand{\g}{...} is not really useful actually, such one - letter - macro names will prove shooting oneself into the foot later on – user31729 Dec 27 '18 at 21:55
  • Ok, fair enough, the bold font one was only a side example. Also I see your point about this being problematic. But just out of curiosity, how would I make the Greek letter in the superscript? – Jakub Kryś Dec 27 '18 at 21:57
  • you say you get mu from your macro but you did not show its use, presumably you used {mu} not {\mu} – David Carlisle Dec 27 '18 at 22:02
  • @JakubKryś: I remember \mathbf not useful for greek symbols. You need \boldsymbol – user31729 Dec 27 '18 at 22:03
  • 1
    Indeed, I'm writing up proofs of identities for combinations of gamma matrices and 'slashed' 4-momenta, such as \gamma^\mu \slashed{a} \gamma^\nu \slashed{b} \gamma_\mu – Jakub Kryś Dec 27 '18 at 22:36
3

\textbf is not meant for math mode, so either not useful, doing nothing or will just print another character.

\mathbf is useful for Latin letters and numbers only, but not for other math symbols. One way is to use \boldsymbol from amsmath.

Please do also not use \newcommand{\g}{...} (correcting the missing \ already) -- use 'nice' abbreviations, such as \gamsup, standing for \gamma superscript.

enter image description here

In total, using a bold superscript may be typographically doubtful...

\documentclass{article}

\usepackage{amsmath}

\newcommand{\gamsup}[1]{\gamma^{\boldsymbol{#1}}}

\begin{document}


$\gamsup{\mu}$

\end{document}

Sigh

For the lazy ones...

Use \boldsymbol{\csname#1\endcsname} as superscript, this will work even if the macro name does not exist -- it will display \gamma only then.

\documentclass{article}

\usepackage{amsmath}

\newcommand{\gamsup}[1]{\gamma^{\boldsymbol{\csname#1\endcsname}}}

\begin{document}


$\gamsup{mu}$

\end{document}
  • Forget the bold font example, I shouldn't have used it. Let's focus on getting the Greek letter. I can do \newcommand{\gamsup}[1]{\gamma^{#1}} and then \gamsup{\mu} is going to produce the desired result. But, just out of my curiosity for how the syntax works, what if I wanted the code \gamsup{mu} to work (without the \ inside the argument). What would be the corresponding macro? – Jakub Kryś Dec 27 '18 at 22:09
  • @JakubKryś: That's changing the question, apart from being not really an useful approach, just being laziness. See the edit at the bottom... – user31729 Dec 27 '18 at 22:10
  • That was meant to be my original question, apologies for the confusion. I know it's laziness and your solution is better - I was wondering how to do it the way I described it in the comment above, just for the sake of it. – Jakub Kryś Dec 27 '18 at 22:13
  • @JakubKryś: As I wrote: see at the end of my answer... I don't recommend it, however – user31729 Dec 27 '18 at 22:17
  • 1
    Thanks, lesson learnt. I won't use it, but it's good to know how one could do it. – Jakub Kryś Dec 27 '18 at 22:20
1

You want syntax like \g{\mu}.

As for getting the symbol you want, in unicode-math, you can use any of the math alphabets (such as \symbfup, \symbfit, or \mathbf) or the macros defined by the package.

If you need code that runs on PDFLaTeX, the isomath package provides a comprehensive selection of math alphabets that include Greek letters in different styles, with a standardized interface. In addition to bold upright, it adds new bold italic, sans-serif and sans-serif bold math alphabets, all of which support Greek. The most compatible command for upright bold math letters is \mathbold{\mu}. However, be aware that there are very few legacy math fonts with unslanted bold Greek letters, and some of them, such as AMS Euler and Fourier, use a non-standard encoding.

You can also use any legacy Greek text font in the LGR encoding with mathastext.

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.