[Tex/LaTex] How to do dot inside a letter

circleslettersmath-modesymbols

A First Course in Complex Analysis by Matthias Beck, Gerald Marchesi, Dennis Pixton, and Lucas Sabalka Ch9.1

enter image description here

Circle: $C[z_0,R] = |z-z_0| = R$

Disc: $D[z_0,R] = |z-z_0| < R$

Closed Disc: $\overline{D}[z_0,R] = |z-z_0| \le R$

Punctured disc: $0 < |z-z_0| < R$

How do I do the dot inside the $D$ to denote a punctured disc?

Best Answer

It's among the worst notation I have ever seen.

If you really want it, at least do it right, with the dot in the middle of the D.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\usepackage{mathpazo}

\NewDocumentCommand{\disk}{smm}{%
  \IfBooleanTF{#1}{\puncturedD}{D}[#2,#3]%
}

\makeatletter
\newcommand{\puncturedD}{{\vphantom{D}\mathpalette\punctured@D\relax}}
\newcommand{\punctured@D}[2]{%
  \sbox\z@{$\m@th#1D$}
  \ooalign{%
    $\m@th#1D$\cr
    \noalign{\punctured@adj{#1}}
    \hidewidth$\m@th#1\mkern1mu\cdot$\hidewidth\cr
  }%
}
\newcommand{\punctured@adj}[1]{%
  \kern\dimexpr\fontdimen22
  \ifx#1\displaystyle\textfont\else
  \ifx#1\textstyle\textfont\else
  \ifx#1\scriptstyle\scriptfont\else
  \scriptscriptfont\fi\fi\fi 2
  -\ht\z@/2\relax
}
\makeatother

\begin{document}

\begin{gather}
\disk*{z_0}{R}=
\{z\in\mathbb{C}:0<\lvert z-z_0\rvert<R\}=
\disk{z_0}{R}\setminus\{z_0\}
\\
\disk*{0}{1} \scriptstyle \disk*{0}{1} \scriptscriptstyle \disk*{0}{1}
\end{gather}

\end{document}

enter image description here

The only “manual” adjustment is \mkern1mu to shift the dot a bit to the right. The amount of shifting depends on the font and the shape of the D, so it cannot be made automatic.


A more complete version with syntax support also for the closed disk.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\usepackage{mathpazo}

\NewDocumentCommand{\disk}{st-mm}{%
  \IfBooleanTF{#1}{\puncturedD}{%
    \IfBooleanTF{#2}{\,\overline{\!D\!}\,}{D}%
  }%
  [#3,#4]%
}

\makeatletter
\newcommand{\puncturedD}{{\vphantom{D}\mathpalette\punctured@D\relax}}
\newcommand{\punctured@D}[2]{%
  \sbox\z@{$\m@th#1D$}
  \ooalign{%
    $\m@th#1D$\cr
    \noalign{\punctured@adj{#1}}
    \hidewidth$\m@th#1\mkern1mu\cdot$\hidewidth\cr
  }%
}
\newcommand{\punctured@adj}[1]{%
  \kern\dimexpr\fontdimen22
  \ifx#1\displaystyle\textfont\else
  \ifx#1\textstyle\textfont\else
  \ifx#1\scriptstyle\scriptfont\else
  \scriptscriptfont\fi\fi\fi 2
  -\ht\z@/2\relax
}
\makeatother

\begin{document}

\begin{gather}
\disk{z_0}{R}=
\{z\in\mathbb{C}:\lvert z-z_0\rvert<R\}
\\
\disk-{z_0}{R}=
\{z\in\mathbb{C}:\lvert z-z_0\rvert\le R\}
\\
\disk*{z_0}{R}=
\{z\in\mathbb{C}:0<\lvert z-z_0\rvert<R\}=
\disk{z_0}{R}\setminus\{z_0\}
\\
\disk*{0}{1} \scriptstyle \disk*{0}{1} \scriptscriptstyle \disk*{0}{1}
\end{gather}

\end{document}

enter image description here

The advantage of having a unified syntax is that if, for instance, you decide for \dot{D} instead of \puncturedD, you can just change the call in the definition of \disk.