3

When placing nodes next to each other, some with and some without math, the vertical alignment of the text ends up looking mismatched between the two nodes (example below). Is there an easy way to align the bottom lines of each line of text with each other? I.e. as if the complete lines are: "Text with [] Text" and "some Math_f [] without".

Example image:

Example image

Minimal example:

\documentclass[]{article}

\usepackage{tikz}
\begin{document}

\tikzset{mystyle/.style={rectangle, text centered, inner sep=5pt, text width=2cm, draw=black}}

\begin{tikzpicture}[node distance=3cm]

\node (node1) [mystyle] {Text with some $Math_f$};
\node (node2) [mystyle, right of=node1] {Text without};

\end{tikzpicture}

\end{document}
6

You can add depth and height to the text in the style you have created.

\tikzset{mystyle/.style={rectangle, align=center, inner sep=5pt,
 text width=2cm,text depth=1.5em,text height=1em, draw=black}}

screenshot

\documentclass[]{article}

\usepackage{tikz}
\begin{document}

\tikzset{mystyle/.style={rectangle, align=center, inner sep=5pt, text width=2cm,text depth=1.5em,text height=1em, draw=black}}

\begin{tikzpicture}[node distance=3cm]

\node (node1) [mystyle] {Text with some $Math_f$};
\node (node2) [mystyle, right of=node1,] {Text without};

\end{tikzpicture}

\end{document}
3

Use \vphantom

\documentclass[]{article}

\usepackage{tikz}
\begin{document}

\tikzset{mystyle/.style={rectangle, text centered, inner sep=5pt, text width=2cm, draw=black}}

\begin{tikzpicture}[node distance=3cm]

\node (node1) [mystyle] {Text with some $Math_f$};
\node (node2) [mystyle, right of=node1] {Text without \vphantom{$Math_f$}};

\end{tikzpicture}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.