13

What commands would be the best way to put numbers above, below, left, and right of a symbol in math-mode, as in the following image:

Would the tensor package be useful here, or possibly another package? Thank you.

Edit:

It looks like David's \mathop workaround works for display style, but not inline math mode. How would one fix it to work for inline, or perhaps use two different commands for inline and display mode?

Secondly, how would I shrink the size of the numbers with respect to the central symbol?

  • WRT your edit: \displaystyle. – Davislor Jul 31 at 23:01
15

This seems to reproduce well the formula at page 9 of https://arxiv.org/pdf/1309.0155.pdf

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}

\makeatletter
\newcommand{\around}[5]{%
  % first is the center, then the letters from bottom in clockwise fashion
  \setbox\z@=\vbox{
    \hbox{\around@sss{#2}}
    \hbox{\around@sss{#3}$\m@th#1$\around@sss{#5}}
    \hbox{\around@sss{#4}}
  }%
  \hbox to \wd\z@{%
    \hss
    \vbox{\offinterlineskip\m@th\scriptspace=0pt
      \ialign{%
        \hfil##\hfil\cr
        \hidewidth\around@sss{#4}\hidewidth\cr
        \noalign{\kern1pt}
        \vtop{\ialign{\hfil##\hfil\cr
          \raisebox{\fontdimen22\textfont2}{\around@sss{#3}}%
          $#1$%
          \raisebox{\fontdimen22\textfont2}{\around@sss{#5}}%
          \cr
          \noalign{\kern1pt}
          \hidewidth\around@sss{#2}\hidewidth\cr
        }}\cr
      }%
    }\hss
  }%
}
\newcommand{\around@sss}[1]{$\m@th\scriptscriptstyle#1$}
\makeatother

\begin{document}

$\around{\mathfrak{A}}{m}{n}{p}{q}\otimes\around{\mathfrak{A}}{m'}{q}{p'}{n'}
\to\around{\mathfrak{A}}{m+m'}{n}{p+p'}{n'}$

\end{document}

enter image description here

Actually, the paper uses TikZ for the job. Compare the results, top line my macro, bottom line the paper's.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz}

\newcommand{\putaround}[5]{
\begin{tikzpicture}[baseline=(A.base),inner sep=0ex]
\node [label={[label distance=.15ex]below:$\scriptscriptstyle #2$},
 label={[label distance=-.1ex, text depth=0pt, text height=0.5ex]left:$\scriptscriptstyle #3$}, 
 label={[label distance=.15ex]above:$\scriptscriptstyle #4$},
 label={[label distance=-.1ex, text depth=0pt, text height=0.5ex]right:$\scriptscriptstyle #5$}] (A)
{$#1$};
\end{tikzpicture}
}


\makeatletter
\newcommand{\around}[5]{%
  % first is the center, then the letters from bottom in clockwise fashion
  \setbox\z@=\vbox{
    \hbox{\around@sss{#2}}
    \hbox{\around@sss{#3}$\m@th#1$\around@sss{#5}}
    \hbox{\around@sss{#4}}
  }%
  \hbox to \wd\z@{%
    \hss
    \vbox{\offinterlineskip\m@th\scriptspace=0pt
      \ialign{%
        \hfil##\hfil\cr
        \hidewidth\around@sss{#4}\hidewidth\cr
        \noalign{\kern1pt}
        \vtop{\ialign{\hfil##\hfil\cr
          \raisebox{\fontdimen22\textfont2}{\around@sss{#3}}%
          $#1$%
          \raisebox{\fontdimen22\textfont2}{\around@sss{#5}}%
          \cr
          \noalign{\kern1pt}
          \hidewidth\around@sss{#2}\hidewidth\cr
        }}\cr
      }%
    }\hss
  }%
}
\newcommand{\around@sss}[1]{$\m@th\scriptscriptstyle#1$}
\makeatother

\begin{document}

\begin{gather}
\around{\mathfrak{A}}{m}{n}{p}{q}\otimes\around{\mathfrak{A}}{m'}{q}{p'}{n'}
\to\around{\mathfrak{A}}{m+m'}{n}{p+p'}{n'}
\\
\putaround{\mathfrak{A}}{m}{n}{p}{q}\otimes\around{\mathfrak{A}}{m'}{q}{p'}{n'}
\to\putaround{\mathfrak{A}}{m+m'}{n}{p+p'}{n'}
\end{gather}

\end{document}

enter image description here

  • Although :correct", the lower "limit" m seems a bit tight. Adding a bit of height (say \vphantom{t}) might improve the appearance. – barbara beeton Aug 18 at 13:51
14

enter image description here

this uses \mathop to get symbols centred on the math axis then { } to remove the extra horizontal spacing that \mathop introduces.

\documentclass{article}
\usepackage{amsfonts}
\begin{document}

\[{\mathop{\scriptstyle n}}{\mathop{\mathfrak{A}}\limits_m^p}{\mathop{\scriptstyle q}}\]
\end{document}
  • Thank you so much! – Ian Montague Jul 31 at 20:04
  • 1
    @IanMontague I did wonder if you wanted all four numbers to be \scriptscriptstyle rather than \scriptstyle a bit hard to tell from the original image – David Carlisle Jul 31 at 20:07
  • I'm not quite sure - the image was taken from page 9 of this paper: arxiv.org/pdf/1309.0155.pdf – Ian Montague Jul 31 at 20:44
  • 3
    @IanMontague if it's arxiv can't you download the tex source? – David Carlisle Jul 31 at 20:55
  • I simply do not understand why you don’t add \limits: I’m afraid i must withhold my upvote until you do so. – GuM Aug 1 at 0:12
6

Using stackrel package + \stackbin option, you can obtain this:

Note: This code is only for this combination of these characters because every another letters could be change the position of n and q.

enter image description here

\documentclass{article}
\usepackage{amsfonts}
\usepackage{stackrel}

\begin{document}
    $\stackbin[m]{p}{\mathfrak{A}}\mkern-22mu{\scriptstyle n}{\phantom{aa}}\mkern-6mu{\scriptstyle q}$
\end{document}

Thus with this MWE you will have not any problems for the position of the characters.

enter image description here

\documentclass{article}
\usepackage{amsfonts}
\usepackage{stackrel}
\begin{document}
    ${\scriptstyle n}\stackbin[m]{p}{\mathfrak{A}}{\scriptstyle q}$
\end{document}
1

This is using TikZ also, but somehow simpler egreg's answer. TikZ controls everything: the center and around symbol with their scaling and distance, as well as horizontal alignment with other texts or formulars (via optionbaseline=(A.mid)).

enter image description here

\documentclass{article}
\usepackage{amsfonts,tikz}
\newcommand{\putaround}[8]{%
% #1 center char
% #2 scale rate of center char
% #3,4,5,6 around chars
% #7 scale rate of around char
% #8 distance from center to around
\begin{tikzpicture}[baseline=(A.mid)]
\path
(0,0)     node[scale=#2] (A) {#1}
+(0:#8)   node[scale=#7]     {#3}
+(90:#8)  node[scale=#7]     {#4}
+(180:#8) node[scale=#7]     {#5}
+(270:#8) node[scale=#7]     {#6};
\end{tikzpicture}
}%
\begin{document}
This is inline symbol \putaround{$\mathfrak{A}$}{1}{$q$}{$p$}{$m$}{$n$}{.8}{.3}
 that TikZ controls everything: the center and around symbol with their scaling and distance, as well as horizontal alignment with other texts or formulars. And below is around symbol with display style 
\[
\putaround{$\mathfrak{A}$}{2}{$q$}{$p$}{$m$}{$n$}{1}{.6}
=\int_0^1 f(x) dx.
\]
\end{document}
  • 1
    @Sebastiano It's my bad habit. Should we use \[ ... \] ,right? – Black Mild Aug 18 at 11:48
  • Thanks! I changed to \[ ... \] as you suggested. – Black Mild Aug 18 at 11:51
  • please keep it! others may learn from that – Black Mild Aug 18 at 11:53
  • 1
    They were only simple comments :-( and not very important for your code. – Sebastiano Aug 18 at 11:54

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.