【问题标题】:LaTeX nodes with text do not align vertically带有文本的 LaTeX 节点不垂直对齐
【发布时间】:2021-09-29 21:55:17
【问题描述】:

我想垂直对齐两个节点中的文本。我目前的实现如下:

\begin{figure}
    \centering
    \begin{tikzpicture}
        \node[anchor=west] at (0,0) {depot};
        \node[anchor=west] at (2,0) {satellite};        
    \end{tikzpicture}
\end{figure}

这会返回下图

如您所见,单词在垂直方向上并没有很好地对齐。这是由仓库中的“p”引起的。我应该向 \node 添加什么参数以使它们垂直对齐?

【问题讨论】:

    标签: latex


    【解决方案1】:

    使用\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}
    

    【讨论】:

    • 完美。非常感谢!
    • @StudentNL 不客气!
    猜你喜欢
    • 2015-11-27
    • 2018-05-16
    • 1970-01-01
    • 2011-01-20
    • 1970-01-01
    • 2015-01-21
    • 1970-01-01
    • 2018-12-26
    • 1970-01-01
    相关资源
    最近更新 更多