¿Es posible crear texto basado en Tikz?

¿Es posible crear texto basado en Tikz?

En uno de mis gráficos de Tikz, he creado un círculo simple lleno de rojo:

\addplot [mark=*, mark size=3, mark options={solid, fill=red}] coordinates {
(1.25, 0) };

Ahora me gustaría hacer referencia a ese círculo en el texto, así que me preguntaba si es posible crear un comando que, cuando esté alineado con el texto, reproduzca el mismo círculo.

EDITAR

La posible solución casi funciona en el título de la figura:

ingrese la descripción de la imagen aquí

Respuesta1

El círculo también se puede dibujar en TikZ; plottambién acepta markopciones:

\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
  \tikz\path plot[
    mark=*,
    mark size=3,
    mark options={solid, fill=red},
  ] coordinates {(0, 0)};%
}
\begin{document}
Circle: \RedCircle
\end{document}

Resultado

Centrado vertical alrededor del eje matemático

El símbolo centrado encaja mejor entre paréntesis.

\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
  \ensuremath{\vcenter{\hbox{%
    \tikz\path plot[
      mark=*,
      mark size=3,
      mark options={solid, fill=red},
    ] coordinates {(0, 0)};%
  }}}%
}
\begin{document}
Circle (\RedCircle)
\end{document}

Resultado

Corrección del cuadro delimitador

TikZ parece olvidarse de tener en cuenta el ancho de línea de la marca para el cuadro delimitador. El siguiente código agrega un pequeño marco para compensar esto:

\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
  \ensuremath{\vcenter{\hbox{%
    \setlength{\fboxsep}{.21pt}%
    % 0.2pt (half line width)
    % + 0.01pt to get some rounding tolerance
    \setlength{\fboxrule}{0pt}%
    \fbox{%
      \tikz\path plot[
        mark=*,
        mark size=3,
        mark options={solid, fill=red, draw=black},
      ] coordinates {(0, 0)};%
    }%
  }}}%
}
\begin{document}
% Show bounding box:
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}
(\textcolor{cyan}{\fbox{\RedCircle}})
\end{document}

Agregando el margen dentro de TikZ (tal vez, la imagen se recorta al externalizar):

\documentclass{article}
\usepackage{tikz}
\newcommand*{\RedCircle}{}
\DeclareRobustCommand*{\RedCircle}{%
  \ensuremath{\vcenter{\hbox{%
    \def\BoundingBoxCorrection{.55\pgflinewidth}%
    % .5\pgflinewidth: half the line width, forgotten by TikZ
    % .05\pgflinewidth: some tolerance for rounding errors
    \tikz\path plot[
        mark=*,
        mark size=3,
        mark options={solid, fill=red, draw=black},
      ] coordinates {(0, 0)}
      (current bounding box.south west)
      ++(-\BoundingBoxCorrection, -\BoundingBoxCorrection)
      (current bounding box.north east)
      ++(\BoundingBoxCorrection, \BoundingBoxCorrection)
    ;%
  }}}%
}
\begin{document}
% Show bounding box:
\setlength{\fboxsep}{0pt}
\setlength{\fboxrule}{.1pt}
(\textcolor{cyan}{\fbox{\RedCircle}})
\end{document}

Resultado

información relacionada