让最后一个方块与前两个方块对齐的最简单方法是什么?我是否需要创建一个\newcolumntype
以某种方式将内容垂直和水平居中的方块?如果是这样,我该怎么做?
\documentclass{article}
\usepackage{tikz}
\usepackage{tabularx}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabularx}{16cm}{C{5cm}C{5cm}Y}
\begin{tikzpicture}[scale=0.7]
\draw (0,0) rectangle (4,4);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.7]
\draw (0,0) rectangle (4,4);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.7]
\draw (0,0) rectangle (4,4);
\end{tikzpicture}\\
\end{tabularx}
\end{document}
答案1
文档建议使用X
以下方式更改列的格式
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}
虽然结果对于文本块来说太宽了,但这似乎在这里有效,所以我添加geometry
并留出了更多的空间。
\documentclass{article}
\usepackage{tikz,geometry}
\geometry{scale=.8}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{>{\centering\arraybackslash}m{#1}}% from the documentation
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newcolumntype{Y}{>{\centering\arraybackslash}X}
\begin{document}
\begin{tabularx}{16cm}{C{5cm}C{5cm}Y}
\begin{tikzpicture}[scale=0.7]
\draw (0,0) rectangle (4,4);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.7]
\draw (0,0) rectangle (4,4);
\end{tikzpicture}
&
\begin{tikzpicture}[scale=0.7]
\draw (0,0) rectangle (4,4);
\end{tikzpicture}\\
\end{tabularx}
\end{document}