绘制半圆盘以供数学模式使用的宏

绘制半圆盘以供数学模式使用的宏

我想定义宏,以便能够在数学模式中使用以下六种形状中的每一个作为下标。

我尝试使用 tikz 来绘制它们,但我不知道是否可以将它们用作下标。

在此处输入图片描述

答案1

图片模式!

\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e}

\DeclareRobustCommand{\fullcircle}{%
  \mspace{2mu}\mathord{
    \sbox{0}{$\scriptstyle O$}%
    \setlength{\unitlength}{\ht0}%
    \begin{picture}(1,1)
    \put(0.5,0.5){\arc{0.5}}
    \end{picture}
  }\mspace{2mu}
}
\DeclareRobustCommand{\upsemicircle}{%
  \mspace{2mu}\mathord{
    \sbox{0}{$\scriptstyle O$}%
    \setlength{\unitlength}{\ht0}%
    \begin{picture}(1,1)
    \put(0.5,0.5){\arc[0,180]{0.5}}
    \end{picture}
  }\mspace{2mu}
}
\DeclareRobustCommand{\downsemicircle}{%
  \mspace{2mu}\mathord{
    \sbox{0}{$\scriptstyle O$}%
    \setlength{\unitlength}{\ht0}%
    \begin{picture}(1,1)
    \put(0.5,0.5){\arc[180,360]{0.5}}
    \end{picture}
  }\mspace{2mu}
}
\DeclareRobustCommand{\upsemicirclediam}{%
  \mspace{2mu}\mathord{
    \sbox{0}{$\scriptstyle O$}%
    \setlength{\unitlength}{\ht0}%
    \begin{picture}(1,1)
    \moveto(0.5,0.5)
    \circlearc{0.5}{0.5}{0.5}{0}{180}
    \lineto(0.5,0.5)
    \strokepath
    \end{picture}
  }\mspace{2mu}
}
\DeclareRobustCommand{\downsemicirclediam}{%
  \mspace{2mu}\mathord{
    \sbox{0}{$\scriptstyle O$}%
    \setlength{\unitlength}{\ht0}%
    \begin{picture}(1,1)
    \moveto(0.5,0.5)
    \circlearc{0.5}{0.5}{0.5}{180}{360}
    \lineto(0.5,0.5)
    \strokepath
    \end{picture}
  }\mspace{2mu}
}
\DeclareRobustCommand{\diam}{%
  \mspace{2mu}\mathord{
    \sbox{0}{$\scriptstyle O$}%
    \setlength{\unitlength}{\ht0}%
    \begin{picture}(1,1)
    \Line(0,0.5)(1,0.5)
    \end{picture}
  }\mspace{2mu}
}

\begin{document}

$X_{\fullcircle\upsemicircle\downsemicircle\upsemicirclediam\downsemicirclediam\diam}$

\end{document}

在此处输入图片描述

增强版,可以应对各个级别的符号。

\documentclass{article}
\usepackage{amsmath}
\usepackage{pict2e}

\makeatletter
\DeclareRobustCommand{\fullcircle}{\peter@symbol\peter@fullcircle}
\DeclareRobustCommand{\upsemicircle}{\peter@symbol\peter@upsemicircle}
\DeclareRobustCommand{\downsemicircle}{\peter@symbol\peter@downsemicircle}
\DeclareRobustCommand{\upsemicirclediam}{\peter@symbol\peter@upsemicirclediam}
\DeclareRobustCommand{\downsemicirclediam}{\peter@symbol\peter@downsemicirclediam}
\DeclareRobustCommand{\diam}{\peter@symbol\peter@diam}

\newcommand{\peter@symbol}[1]{\mathord{\mspace{2mu}\mathpalette#1\relax\mspace{2mu}}}
\newcommand{\peter@unitlength}[1]{%
  \settoheight{\unitlength}{$\m@th#1O$}%
  \linethickness{\fontdimen 8
    \ifx#1\displaystyle\textfont\else
    \ifx#1\textstyle\textfont\else
    \ifx#1\scriptstyle\scriptfont\else
    \scriptscriptfont\fi\fi\fi 3
  }%
}

\newcommand{\peter@fullcircle}[2]{%
  \begingroup
  \peter@unitlength{#1}%
  \begin{picture}(1,1)
  \circlearc[1]{0.5}{0.5}{0.5}{0}{360}
  \strokepath
  \end{picture}%
  \endgroup
}
\newcommand{\peter@upsemicircle}[2]{%
  \begingroup
  \peter@unitlength{#1}%
  \begin{picture}(1,1)
  \circlearc[1]{0.5}{0.5}{0.5}{0}{180}
  \strokepath
  \end{picture}%
  \endgroup
}
\newcommand{\peter@downsemicircle}[2]{%
  \begingroup
  \peter@unitlength{#1}%
  \begin{picture}(1,1)
  \circlearc[1]{0.5}{0.5}{0.5}{180}{360}
  \strokepath
  \end{picture}%
  \endgroup
}
\newcommand{\peter@upsemicirclediam}[2]{%
  \begingroup
  \peter@unitlength{#1}%
  \begin{picture}(1,1)
  \moveto(0.5,0.5)
  \circlearc{0.5}{0.5}{0.5}{0}{180}
  \lineto(0.5,0.5)
  \strokepath
  \end{picture}%
  \endgroup
}
\newcommand{\peter@downsemicirclediam}[2]{%
  \begingroup
  \peter@unitlength{#1}%
  \begin{picture}(1,1)
  \moveto(0.5,0.5)
  \circlearc{0.5}{0.5}{0.5}{180}{360}
  \lineto(0.5,0.5)
  \strokepath
  \end{picture}%
  \endgroup
}
\newcommand{\peter@diam}[2]{%
  \begingroup
  \peter@unitlength{#1}%
  \begin{picture}(1,1)
  \Line(0,0.5)(1,0.5)
  \end{picture}%
  \endgroup
}

\begin{document}

$X\fullcircle\upsemicircle\downsemicircle\upsemicirclediam\downsemicirclediam\diam$

$X_{\fullcircle\upsemicircle\downsemicircle\upsemicirclediam\downsemicirclediam\diam}$

$X_{X_{\fullcircle\upsemicircle\downsemicircle\upsemicirclediam\downsemicirclediam\diam}}$

\end{document}

在此处输入图片描述

答案2

盒子里的 Z!(不幸的是,远远不如图片模式)

\documentclass[]{article}

\usepackage{tikz}

\makeatletter
\newcommand\setup@crazysubscripts[2]
  {%
    \expandafter\newsavebox\csname crazysubscripts@#1\endcsname
    \expandafter\sbox\csname crazysubscripts@#1\endcsname
      {%
        \kern.1ex
        \begin{tikzpicture}
          \path[use as bounding box] circle[radius=.5ex];
          #2%
        \end{tikzpicture}%
        \kern.1ex
      }%
  }
\setup@crazysubscripts{fc}% fullcircle
  {%
    \draw circle[radius=.5ex];%
  }
\setup@crazysubscripts{lo}% lower open
  {%
    \draw (.5ex,0) arc[start angle=0, end angle=-180, radius=.5ex];%
  }
\setup@crazysubscripts{uo}% upper open
  {%
    \draw (.5ex,0) arc[start angle=0, end angle=180, radius=.5ex];%
  }
\setup@crazysubscripts{lc}% lower closed
  {%
    \draw (-.5ex,0) -- (.5ex,0) arc[start angle=0, end angle=-180, radius=.5ex]
      --cycle;%
  }
\setup@crazysubscripts{uc}% upper closed
  {%
    \draw (-.5ex,0) -- (.5ex,0) arc[start angle=0, end angle=180, radius=.5ex]
      --cycle;%
  }
\setup@crazysubscripts{b}% boring line
  {%
    \draw (-.5ex,0) -- (.5ex,0);%
  }
\newcommand\csubs[1]
  {%
    \@ifundefined{crazysubscripts@#1}
      {\GenericError{}{Undefined crazysubscript `#1`}{}{}}%
      {%
        \resizebox{.75ex}{!}
          {\expandafter\usebox\csname crazysubscripts@#1\endcsname}%
      }%
  }
\makeatother

\begin{document}
$A_{\csubs{fc}_{\csubs{lo}_{\csubs{lc}}}}$

\csubs{fc}\csubs{lo}\csubs{uo}\csubs{lc}\csubs{uc}\csubs{b}
\end{document}

在此处输入图片描述

答案3

只是一个模板。

\documentclass[preview,border=12pt,varwidth,12pt]{standalone}
\usepackage{tikz}

\def\alex{\tikz \draw (0,0) circle (2pt);}
\def\bobby{\tikz \draw (0,0) -- (3pt,0) -- (3pt,2pt) -- cycle;}
\begin{document}
This is an  equation $F_{\alex}^{\bobby}+1$.
\end{document}

在此处输入图片描述

相关内容