松散的符号对齐

松散的符号对齐

我正在尝试使用 Tikz 创建数字。我对数字的外观很满意,尽管 9 与其他数字不对齐。我怀疑这是其代码的“松散”组件,但我不能 100% 确定。有没有其他方法可以定义 9,使其看起来像下面的数字,但与 7 和 8 水平对齐?谢谢。

在此处输入图片描述

\documentclass{beamer}
\usepackage{tikz}

\newcommand{\Seven}{
\begin{tikzpicture}
\draw [white] (0,-0.5) -- (0,0.5) -- (0.6,0.5);
\draw[ultra thick, line cap=round] (0.0,0.4) -- (0.5,0.4) -- (0.2,-0.5);
\end{tikzpicture}}

\newcommand{\Eight}{
\begin{tikzpicture}
\draw [white] (0,-0.5) -- (0,0.5) -- (0.6,0.5);
\draw[ultra thick] (0.25,0.4) arc(90:-90:0.2cm and 0.2cm);
  \draw[ultra thick] (0.25,0.4) arc(90:270:0.2cm and 0.2cm);
   \draw[ultra thick] (0.25,0) arc(90:-90:0.25cm and 0.25cm);
  \draw[ultra thick] (0.25,0) arc(90:270:0.25cm and 0.25cm);
\end{tikzpicture}}


\newcommand{\NineA}{
\begin{tikzpicture}
\draw [white] (0,-0.5) -- (0,0.5) -- (0.6,0.5);
% \draw[ultra thick, line cap=round] (0.2,0.15) circle[x radius=0.25,y radius=0.25]; 
    \draw[ultra thick, line cap=round] (0.45,-0.5) -- coordinate[pos=0.5](-mid)(0.45,0.4);
    \draw[ultra thick, line cap=round]   (0.45,0.4) to[out=170,in=260,looseness=25]   (0.45,0.3);   
\end{tikzpicture}}

\begin{document}

\begin{frame}
  \Seven\\
\Eight \\
\NineA  
\end{frame}


\end{document}

答案1

你的怀疑是正确的,一个可能的补救措施是使用bboxtikz 库。它在这种情况下提供贝塞尔曲线周围的紧密边界框:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{bbox}   % <---

\newcommand{\Seven}{
\begin{tikzpicture}
\draw [white] (0,-0.5) -- (0,0.5) -- (0.6,0.5);
\draw[ultra thick, line cap=round] (0.0,0.4) -- (0.5,0.4) -- (0.2,-0.5);
\end{tikzpicture}}

\newcommand{\Eight}{
\begin{tikzpicture}
\draw [white] (0,-0.5) -- (0,0.5) -- (0.6,0.5);
\draw[ultra thick] (0.25,0.4) arc(90:-90:0.2cm and 0.2cm);
  \draw[ultra thick] (0.25,0.4) arc(90:270:0.2cm and 0.2cm);
   \draw[ultra thick] (0.25,0) arc(90:-90:0.25cm and 0.25cm);
  \draw[ultra thick] (0.25,0) arc(90:270:0.25cm and 0.25cm);
\end{tikzpicture}}

\newcommand{\NineA}{
\begin{tikzpicture}[bezier bounding box]    % <---
\draw [white] (0,-0.5) -- (0,0.5) -- (0.6,0.5);
% \draw[ultra thick, line cap=round] (0.2,0.15) circle[x radius=0.25,y radius=0.25];
    \draw[ultra thick, line cap=round] (0.45,-0.5) -- coordinate[pos=0.5](-mid)(0.45,0.4);
    \draw[ultra thick, line cap=round]   (0.45,0.4) to[out=170,in=260,looseness=25]   (0.45,0.3);
\end{tikzpicture}}

\begin{document}

\begin{frame}
\Seven\\
\Eight \\
\NineA
\end{frame}

\end{document}

在此处输入图片描述

相关内容