
答案1
試試以下骯髒的伎倆:
\documentclass{article}
\usepackage{array, tabu}
\begin{document}
\begin{table}[h]
\begin{tabu} to 1.0\textwidth { |X[c,$] | X[c,$]m{0pt}|}
\hline
N_{1} & (0: 1] & \\[3cm] \hline
\end{tabu}
\end{table}
\end{document}
目前尚不清楚為什麼需要如此奇怪的表格設計。而且包的使用tabu
很棘手。它沒有維護並且包含錯誤......
附錄:單元格內容的垂直居中並不是簡單的任務。為此,m{0pt}
在上面的範例中新增了一個假列,其中行的基線垂直居中。
為了使表格中的儲存格內容水平居中tabularx
,您需要定義新的列類型,例如
\newcolumntype{C}{>{\centering\arraybackslash}X}
如果整列的內容處於數學模式,那麼整列定義為這種模式是明智的。那你就不需要在每個儲存格中寫入$<math expression>$
。在這種情況下,您可以將新的列類型定義為:
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}
Complete code is then:
\documentclass{article}
\usepackage{tabularx}
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}
\begin{document}
\begin{table}[h]
\begin{tabularx}{\textwidth}{ | C | C @{}m{0pt}|}
\hline
N_{1} & (0: 1] & \\[3cm] \hline
\end{tabularx}
\end{table}
\end{document}
正如您所看到的,這裡也使用了與之前相同的技巧。與第一個範例相比,結果略有改善,因為在上面的 MWE 中消除了@{}
列間空間。
附錄2:
目前尚不清楚為什麼要\\[3cm]
在儲存格內容周圍留出更多垂直空間。透過更改可以實現類似的效果,但問題更少\arraystretch
,例如,透過在單元格中添加更合理的垂直空間,您可以按以下方式設計表格:
\documentclass{article}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}% <-- cell's contend is vertically centered
\newcolumntype{C}{>{\centering\arraybackslash $}X<{$}}
\begin{document}
\begin{table}[h]
\renewcommand{\arraystretch}{3}
\setlength{\extrarowheight}{-2.5pt}% <-- correction of vertical centering
\begin{tabularx}{\textwidth}{ | C | C |}
\hline
N_{1}
& (0: 1] \\ \hline
\end{tabularx}
\end{table}
\end{document}
正如您所看到的,現在沒有添加假列。