带有文本的 LaTeX 节点不垂直对齐
LaTeX nodes with text do not align vertically
我想垂直对齐两个节点中的文本。我目前的实现如下:
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=west] at (0,0) {depot};
\node[anchor=west] at (2,0) {satellite};
\end{tikzpicture}
\end{figure}
这个returns下图
如您所见,单词在垂直方向上没有很好地对齐。这是由 depot 中的“p”引起的。我应该向 \node 添加什么参数以使它们垂直对齐?
使用 \strut
你可以“伪造”一个最大高度和深度的字母:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=west] at (0,0) {depot\strut};
\node[anchor=west] at (2,0) {satellite\strut};
\end{tikzpicture}
\end{figure}
\end{document}
或者如果您不需要 west
锚点,您可以使用
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=base] at (0,0) {depot};
\node[anchor=base] at (2,0) {satellite};
\end{tikzpicture}
\end{figure}
\end{document}
我想垂直对齐两个节点中的文本。我目前的实现如下:
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=west] at (0,0) {depot};
\node[anchor=west] at (2,0) {satellite};
\end{tikzpicture}
\end{figure}
这个returns下图
如您所见,单词在垂直方向上没有很好地对齐。这是由 depot 中的“p”引起的。我应该向 \node 添加什么参数以使它们垂直对齐?
使用 \strut
你可以“伪造”一个最大高度和深度的字母:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=west] at (0,0) {depot\strut};
\node[anchor=west] at (2,0) {satellite\strut};
\end{tikzpicture}
\end{figure}
\end{document}
或者如果您不需要 west
锚点,您可以使用
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\node[anchor=base] at (0,0) {depot};
\node[anchor=base] at (2,0) {satellite};
\end{tikzpicture}
\end{figure}
\end{document}