LaTeX nodes with text do not align vertically

Viewed 1452

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?

1 Answers

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 if you don't need your west anchor, you can use

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