latex

LaTeX nodes with text do not align vertically


I would like to align the text in two nodes vertically. My current implementation is as follows:

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

This returns the following figure

enter image description here

As you can see, the words are not well aligned in the vertical direction. This is caused by the "p" in depot. What argument should I add to \node to have them vertically aligned?


Solution

  • With \strut you can "fake" a letter of maximal height and depth:

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

    ... or you anchor on base west:

    \documentclass{article}
    
    \usepackage{tikz}
    
    \begin{document}
    
    \begin{figure}
        \centering
        \begin{tikzpicture}
            \node[anchor=base west] at (0,0) {depot};
            \node[anchor=base west] at (2,0) {satellite};        
        \end{tikzpicture}
    \end{figure}
    
    
    \end{document}