
是否可以將 TikZ 矩陣中一列的單元格垂直居中?新增nodes = {anchor = center}
所有儲存格垂直居中,但我想保留第二列和第三列中儲存格內容的底部對齊。
也就是說,如何asdf
在第一列中垂直居中,但保持第二列和第三列中圖像的底部對齊?
微量元素
\documentclass{article}
\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes]{
asdf & \includegraphics[width=2cm]{example-image-a} & \includegraphics[width=3cm]{example-image-a} \\
};
\end{tikzpicture}
\end{document}
答案1
您可以column 1/.style
只對第一列中的儲存格或row 2 column 3/.style
特定儲存格設定樣式。這裡一些樣式會套用到第一列:
\documentclass{article}
\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,
column 1/.style={anchor=center,color=red,text depth=2cm}]{
asdf & \includegraphics[width=2cm]{example-image-a} & \includegraphics[width=3cm]{example-image-a} \\
bkgi & \includegraphics[width=3cm]{example-image-a} & \includegraphics[width=1cm]{example-image-a} \\
};
\end{tikzpicture}
\end{document}