Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaTeX nodes with text do not align vertically

Tags:

latex

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?

like image 765
Student NL Avatar asked Apr 01 '26 18:04

Student NL


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 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}
like image 61
samcarter_is_at_topanswers.xyz Avatar answered Apr 03 '26 11:04

samcarter_is_at_topanswers.xyz