TeX - LaTeX Asked by jodles on December 7, 2020
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:
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}
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}}
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}
Correct answer by AndréC on December 7, 2020
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}
Answered by Scott Seidman on December 7, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP