在 Latex 中创建带标签的数字线
Create a Labeled Number Line in Latex
如何在 Latex 中创建带有标签而不是数字的数字线?我什至不知道如何开始。
试试这个:
\documentclass[multi=false,tikz,border=2mm]{standalone}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\def\labelz{{"Judicial Independence","Long Label 2","Label 3","Label 4"}}
\draw [<->,>=triangle 45] (0,0) -- (10,0);
\foreach \x in {1,...,4} {%
\draw [<->,>=stealth] (2*\x,-.4) -- (2*\x,.4);
\node at (2*\x,2.4-.4*\x){\pgfmathparse{\labelz[\x-1]}\pgfmathresult};
}
\end{tikzpicture}
\end{document}
然后从这里您可以调整scale
、线条的位置、箭头的形状(reference)。
请注意,如果您感兴趣的内容会根据 \x
发生变化。
相反,改变
\node at (2*\x,2.4-.4*\x)
到
\node [align=center,text width=22mm] at (2*\x,1)
你会得到:
如何在 Latex 中创建带有标签而不是数字的数字线?我什至不知道如何开始。
试试这个:
\documentclass[multi=false,tikz,border=2mm]{standalone}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\def\labelz{{"Judicial Independence","Long Label 2","Label 3","Label 4"}}
\draw [<->,>=triangle 45] (0,0) -- (10,0);
\foreach \x in {1,...,4} {%
\draw [<->,>=stealth] (2*\x,-.4) -- (2*\x,.4);
\node at (2*\x,2.4-.4*\x){\pgfmathparse{\labelz[\x-1]}\pgfmathresult};
}
\end{tikzpicture}
\end{document}
然后从这里您可以调整scale
、线条的位置、箭头的形状(reference)。
请注意,如果您感兴趣的内容会根据 \x
发生变化。
相反,改变
\node at (2*\x,2.4-.4*\x)
到
\node [align=center,text width=22mm] at (2*\x,1)
你会得到: