圆形图的相对定位,TikZ

圆形图的相对定位,TikZ

我正在为我的一门课程制作代谢示意图,但在将圆形图(柠檬酸循环)中的箭头定位在丙酮酸框下方时遇到了麻烦。柠檬酸循环的大部分代码都取自网上,但我不知道如何将框和箭头都向下移动。在此处输入图片描述

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\tikzstyle{Glycolysis} = [rectangle, text centered, draw=black, fill=none, inner sep=0pt]

\begin{tikzpicture}

\node [Glycolysis] (Initial) {Pyruvate};

\end{tikzpicture}

\begin{tikzpicture}
\def \n {9}
\def \radius {6cm}
\def \margin {8}

\foreach \molecule [count=\s] in {A, B, C, D, E, F, G, H, I}
{
  \node[draw, rectangle, below = 5cm of Initial] at ({360/\n * (\s)}:\radius) {\molecule};
  \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
   arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}

\end{tikzpicture}
\end{document}

答案1

您可以删除below=5cm of Initial并放置\vfill两个tikzpicture环境之间的:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{Glycolysis/.style={rectangle, text centered, draw=black, fill=none, inner sep=0pt}}
\begin{document}


\noindent\begin{tikzpicture}

\node [Glycolysis] (Initial) {Pyruvate};

\end{tikzpicture}
\vfill
\noindent\begin{tikzpicture}
\def \n {9}
\def \radius {6cm}
\def \margin {8}

\foreach \molecule [count=\s] in {A, B, C, D, E, F, G, H, I}
{
  \node[draw, rectangle] at ({360/\n * (\s)}:\radius) {\molecule};
  \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
   arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}

\end{tikzpicture}
\end{document}

或者,您可以将所有内容放在一个 中tikzpicture,并将Pyruvate节点放置在圆的上方,例如\node [Glycolysis] (Initial) at (-5,12) {Pyruvate};。圆心在(0,0),默认单位向量为 1cm,因此节点位于圆心左侧 5cm 处,上方 12cm 处。根据您的喜好进行调整。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{Glycolysis/.style={rectangle, text centered, draw=black, fill=none, inner sep=0pt}}
\begin{document}


\noindent\begin{tikzpicture}

\node [Glycolysis] (Initial) at (-5,12) {Pyruvate};

\def \n {9}
\def \radius {6cm}
\def \margin {8}

\foreach \molecule [count=\s] in {A, B, C, D, E, F, G, H, I}
{
  \node[draw, rectangle] at ({360/\n * (\s)}:\radius) {\molecule};
  \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
   arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}

\end{tikzpicture}
\end{document}

附注:如果您只需要在第一个节点的单词周围画一个矩形,则可以使用\framebox,因此另一种方法可能是

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\tikzset{Glycolysis/.style={rectangle, text centered, draw=black, fill=none, inner sep=0pt}}
\begin{document}
\framebox{Pyruvate}

\vfill

\noindent\begin{tikzpicture}
\def \n {9}
\def \radius {6cm}
\def \margin {8}

\foreach \molecule [count=\s] in {A, B, C, D, E, F, G, H, I}
{
  \node[draw, rectangle] at ({360/\n * (\s)}:\radius) {\molecule};
  \draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
   arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}

\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容