2

When writing (co)homological grading, the command \bullet yields a bullet that is too big for my taste, see the example below. Therefore, I usually define a command \smallbullet as below. However, my construction should probably be made more robust using \mathpalette, using ideas similar to this and this. However, if you apply the constructions from these other solutions, you get a bullet with the wrong vertical position. What would be the best (and most robust) way to correct this in my case?

\documentclass{article}

\usepackage{graphicx}

\newcommand\smallbullet{% \raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}% }

\begin{document}

$ H^{\bullet} $

$ H^{\smallbullet} $

\end{document}

enter image description here

Gaussler
  • 12,801

3 Answers3

5

I'd scale down a \bullet, because \cdot has quite wide sidebearings. Here the scale factor is 0.5, adjust to suit.

\documentclass{article}

\usepackage{graphicx}

\makeatletter \newcommand{\smallbullet}{} % for safety \DeclareRobustCommand\smallbullet{% \mathord{\mathpalette\smallbullet@{0.5}}% } \newcommand{\smallbullet@}[2]{% \vcenter{\hbox{\scalebox{#2}{$\m@th#1\bullet$}}}% } \makeatother

\begin{document}

$ H^{\bullet} $

$ H^{\smallbullet} $

\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanks for the answer! One thing I’ve never quite understood is: Why are people using % at the end of lines for math mode-only commands? I understand it for text mode commands where these spaces would actually matter, but not math mode commands. – Gaussler Sep 28 '20 at 11:32
  • 1
    Uniformity, I'd say – egreg Sep 28 '20 at 11:54
  • I tried rewriting your code in expl3, but I am unsure if there are ways to do things better with the new standards? I have posted it as a separate answer. Any comments are welcome. :-) – Gaussler Oct 03 '20 at 10:30
  • @Gaussler As there aren't yet interfaces to \mathpalette or \vcenter, I'm not sure I'd go for expl3 in this case. – egreg Oct 03 '20 at 10:34
  • But if you had to (and I have to, as I intend to use it in an expl3 package), would you do it this way? – Gaussler Oct 03 '20 at 10:36
  • @Gaussler Yes, that's essentially what you should do. Maybe define an own wrapper for \hbox_set:Nn, say \gaussler_math_hbox_set:Nnn, where the first argument is the box register, the second argument a style selection and the third the material to set, so you can add to it \mathsurround=0pt without need to do it explicitly in the macro. Note that \__gaussler_bullet_auxiliary:Nn should be protected as well. – egreg Oct 03 '20 at 10:42
  • But you did not protect your command \smallbullet@? Anyway, why does it matter if it is used inside a robust command anyway? – Gaussler Oct 03 '20 at 10:45
  • @Gaussler Uniformity. – egreg Oct 03 '20 at 12:10
  • Seems you like uniforms a lot. ;-) – Gaussler Oct 03 '20 at 12:12
4

Using for the small\bullet the nice macro of Steven B. Segletes in this question, Is there a black 'dot' symbol that I can use?

\newcommand\sbullet[1][.5]{\mathbin{\ThisStyle{\vcenter{\hbox{%
  \scalebox{#1}{$\SavedStyle\bullet$}}}}}%
}

that I have a bit adapted, I suggest to use \strut to have a better positioning of the bullet as superscript. Here there is a possibile MWE that shows two different size of the bullets in addendum to the classical \bullet.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{graphicx,scalerel}
\newcommand\sbullet[1][.5]{\mathbin{\ThisStyle{\vcenter{\hbox{%
  \scalebox{#1}{$\SavedStyle\bullet$}}}}}%
}
\newcommand\smbullet[1][.8]{\mathbin{\ThisStyle{\vcenter{\hbox{%
  \scalebox{#1}{$\SavedStyle\bullet$}}}}}%
}
\begin{document}
$H\strut^{\bullet}, H\strut^{\sbullet}, H\strut^{\smbullet}$
\end{document}

enter image description here


Using your macro you will have the same and correct height for the \smallbullet or \bullet:

 \documentclass[a4paper,12pt]{article}
    \usepackage{amsmath,amssymb}
    \usepackage{graphicx}
    \newcommand\smallbullet{%
    \raisebox{-0.25ex}{\scalebox{1.2}{$\cdot$}}%
}
\begin{document}
$P\strut^{\bullet}, H\strut^{\smallbullet}$
\end{document}

enter image description here

Sebastiano
  • 54,118
1

I decided to rewrite egreg’s excellent answer in expl3. However, as many TeX concepts (such as \vcenter and \mathpalette) seem to not yet have expl3 analogues, I was forced to mix up old and new standards. I was hoping egreg would comment and tell me if there is something that could be improved?

\documentclass{article}

\usepackage{expl3}

\ExplSyntaxOn

\cs_new_protected:Npn\gaussler_set_mathsurround_to_zero: { % This is equivalent to "\m@th" \dim_set:Nn \mathsurround { 0pt } }

\cs_set_protected:Npn\gaussler_bullet: { \mathord{\mathpalette__gaussler_bullet_auxiliary:Nn{0.5}} }

\box_new:N \l__gaussler_bullet_box

\cs_set_protected:Npn__gaussler_bullet_auxiliary:Nn#1#2 { \hbox_set:Nn \l__gaussler_bullet_box { $\gaussler_set_mathsurround_to_zero: #1 \bullet$ } \box_scale:Nnn \l__gaussler_bullet_box { #2 } { #2 } \vcenter{ \hbox:n { \box_use_drop:N \l__gaussler_bullet_box } } }

\cs_set_eq:NN\smallbullet \gaussler_bullet:

\ExplSyntaxOff

\begin{document}

$ H^{\bullet} $

$ H^{\smallbullet} $

\end{document}

Gaussler
  • 12,801