![tikz 矩陣對齊略有偏差](https://rvso.com/image/309841/tikz%20%E7%9F%A9%E9%99%A3%E5%B0%8D%E9%BD%8A%E7%95%A5%E6%9C%89%E5%81%8F%E5%B7%AE.png)
我知道有很多標題相似的帖子,但不知何故我找不到任何看起來相關的內容。這是一個 MWE,我希望所有行的距離均勻。但顯然第一行和第二行比第二行和第三行更接近:
\documentclass[]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix[
matrix of nodes,
anchor=north,
column 1/.style={nodes={anchor=base west,align=center}},
column 2/.style={nodes={anchor=base west,align=center}},
column 3/.style={nodes={anchor=base west,align=center}},
column 4/.style={nodes={anchor=base west,align=center}}
]
{ Some text& \\
Some text& Some longer text\\
Some text&
Some text\\};
\end{tikzpicture} %
\caption{test test}
\end{figure}
\end{document}
答案1
因為第二行包含g
下行字母的字母,而第一行沒有。您可以將一些添加text depth
到所有節點或\strut
在所有單元格內使用。
\documentclass[]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\matrix[
matrix of nodes,
anchor=north,
nodes={text depth=0.55ex}, %% <----------------------here
column 1/.style={nodes={anchor=base west,align=center}},
column 2/.style={nodes={anchor=base west,align=center}},
column 3/.style={nodes={anchor=base west,align=center}},
column 4/.style={nodes={anchor=base west,align=center}}
]
{ Some text& \\
Some text& Some longer text\\
Some text& Some text\\};
\end{tikzpicture} %
\caption{test test}
\end{figure}
\end{document}