似乎无法绘制非常小的 TikZ 形状?

似乎无法绘制非常小的 TikZ 形状?

我正在尝试绘制适合圆圈的小标签,或者至少与圆圈成比例。但由于某种原因,我似乎无法将它们做得比这更小:

例子

我知道物体的体积可能存在物理极限,但我觉得它应该比图片上显示的要小。

代码如下:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\newlength{\step}

\tikzset{
  buffer/.style={
    draw,
    shape border rotate=0,
    regular polygon,
    regular polygon sides=3,
    fill=red,
    node distance=1pt,
    minimum height=1pt
  }
}

\begin{document}
  \begin{tikzpicture}
    \setlength{\step}{\dimexpr 10cm / 18 \relax}

    \draw[step=\step] (0, 0) grid (10, 10);

    \draw[draw = white, fill = black, line width = 0.1mm]
      (2 * \step, 3 * \step)
      circle [radius = 0.2575cm]
      node[color = white, font={\fontsize{0.1pt}{12}\selectfont}] {1};
    \draw[draw = black, fill = white, line width = 0.1mm]
      (3 * \step, 3 * \step)
      circle [radius = 0.2575cm]
      node[color = black] {2};
    \draw[draw = white, fill = black, line width = 0.1mm]
      (4 * \step, 3 * \step)
      circle [radius = 0.2575cm];
    \draw (3 * \step, 3 * \step) node[
      minimum size=1pt,
      draw] {};
    \draw node[buffer] at (4 * \step, 3 * \step) {};
  \end{tikzpicture}
\end{document}

顺便问一下,为什么 TikZ 形状设置为minimum size? 难道不应该有一个maximum size吗? 为什么不直接size用 ?

答案1

  • 节点内容和周围绘制的形状之间存在一些填充。您可以通过修改参数来调整inner sep

  • 如果要使用极端字体大小(小或大),通常更容易使用可缩放字体,例如通过加载lmodern


\documentclass[border=0.2cm]{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\tikzset{
  buffer/.style={
    draw,
    shape border rotate=0,
    regular polygon,
    regular polygon sides=3,
    fill=red,
    node distance=1pt,
    minimum height=1pt
  }
}

\usepackage{lmodern}

\begin{document}
  \begin{tikzpicture}[inner sep=0pt]
    \node[fill=black,font={\fontsize{0.1}{12}\selectfont}] at (0,0) {1};
    \node[draw] at (1,0) {};
    \node[buffer] at (2,0) {};
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容