将文本垂直居中移动的正确选项是什么?当前代码位于左下方。
%pdflatex -shell-escape a.tex
\def\CONVERTCOMMAND{\convertexe\space -density \density\space \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 -alpha off \outfile}
\documentclass[tikz,convert={true,density = 300,convertexe = {convert},
command = {\noexpand\CONVERTCOMMAND},}]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\matrix (m) at(0.09,0.76) [matrix of nodes,
nodes={draw=blue!20,line width=0,outer sep=0,inner sep=0,text width=4.3cm,text height=28,align=left},%align=center
] {
7/2/23 & AAA & 000 & xxx \\
7/3/23 & BBB & 111 & xxx \\
7/4/23 & CCC & 222 & xxx \\
7/5/23 & DDD & 333 & xxx \\
};
\end{tikzpicture}
\end{document}
答案1
尝试此代码(使用 anchor=center
)
% !TeX TS-program = pdflatex
\def\CONVERTCOMMAND{\convertexe\space -density \density\space \infile\space \ifx\size\empty\else -resize \size\fi\space -quality 90 -alpha off \outfile}
\documentclass[tikz,convert={true,density = 300,convertexe = {convert},
command = {\noexpand\CONVERTCOMMAND},}]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\tikzset{centered matrix/.style={%
matrix of nodes,
nodes={draw=blue!20,line width=0,
minimum height=28pt,
text width=4.3cm,
anchor=center,
align=center,
inner sep=0pt,
},
},
}
\matrix (m) at(0.09,0.76) [centered matrix]
{
7/2/23 & AAA & 000 & xxx \\
7/3/23 & BBB & 111 & xxx \\
7/4/23 & CCC & 222 & xxx \\
7/5/23 & DDD & 333 & xxx \\
};
\end{tikzpicture}
\end{document}