如何用 tikz 将一个圆置于矩形右侧的中心

如何用 tikz 将一个圆置于矩形右侧的中心

我正在尝试在每个矩形上创建一个圆圈。每个圆圈应位于矩形顶部和底部的中心,但应放置在右侧。

代码示例:

\documentclass{article}
\usepackage{tikz}
\usepackage{lscape}
\usepackage{nopageno}
\usepackage{pdflscape}
\usetikzlibrary{shapes.geometric,positioning}
\usepackage{geometry}
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }

\begin{document}
  \begin{landscape}
    \begin{tikzpicture}
      \node at (0,0) [trapezium,
                      name=trapezium,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=.1cm,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      trapezium angle=25] {};
      \node          [name=first,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of trapezium.south] {};
      \node          [name=second,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of first.south] {};
      \node          [name=third,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of second.south] {};
      \node          [name=fourth,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of third.south] {};
      \node at (2,0) [name=firstCircle,
                      circle,
                      fill=white,
                      draw=blue!9!white,
                      minimum size=0.5cm] {};
      \node          [name=secondCircle,
                      circle,
                      fill=white,
                      node distance=1cm,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      below=of firstCircle.south] {};
      \node          [name=thirdCircle,
                      circle,
                      fill=white,
                      node distance=20pt,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      below=of secondCircle.south] {};
      \node          [name=forthCircle,
                      circle,
                      fill=white,
                      node distance=1cm,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      below=of thirdCircle.south] {};
    \end{tikzpicture}
  \end{landscape}
\end{document}

输出示例:

输出

我尝试用 x 和 y 轴进行实验,但由于我想tikzpicture在纸上多次复制这一点,所以我正在寻找一个更有条理的解决方案。

有没有比我做的更好的方法?

答案1

感谢@Qrrbrbirlbel,我终于弄明白了。

我也不得不使用xshift=-5mm

代码示例:

\documentclass{article}
\usepackage{tikz}
\usepackage{lscape}
\usepackage{nopageno}
\usepackage{pdflscape}
\usetikzlibrary{shapes.geometric,positioning}
\usepackage{geometry}
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=20mm,
 top=20mm,
 }

\begin{document}
  \begin{landscape}
    \begin{tikzpicture}
      \node at (0,0) [trapezium,
                      name=trapezium,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=.1cm,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      trapezium angle=25] {};
      \node          [name=first,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of trapezium.south] {};
      \node          [name=second,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of first.south] {};
      \node          [name=third,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of second.south] {};
      \node          [name=fourth,
                      fill=blue!9!white,
                      draw=blue!50!white,
                      rounded corners,
                      line width=.05cm,
                      node distance=.05cm,
                      minimum width=5cm,
                      minimum height=1cm,
                      below=of third.south] {};
      \node at (first.east) [name=firstCircle,
                      circle,
                      fill=white,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      xshift=-5mm] {};
      \node at (second.east) [name=secondCircle,
                      circle,
                      fill=white,
                      node distance=1cm,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      xshift=-5mm] {};
      \node at (third.east) [name=thirdCircle,
                      circle,
                      fill=white,
                      node distance=20pt,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      xshift=-5mm] {};
      \node at (fourth.east) [name=forthCircle,
                      circle,
                      fill=white,
                      node distance=1cm,
                      draw=blue!9!white,
                      minimum size=0.5cm,
                      xshift=-5mm] {};
    \end{tikzpicture}
  \end{landscape}
\end{document}

有没有更好的方法来复制我的形状?我计划再创建至少 5 个这样的形状。

相关内容