
我正在嘗試使用 tabularx 建立一個簡單的三列表,但我一定是誤解了程式碼的某些方面,因為我的表顯然無法正常工作。
我的目標是擁有三個相等的列寬,但無論我如何嘗試,線條似乎都不匹配。 (我還需要努力使文本居中並將“信息”保留為單個單詞,但這些問題相對較小!)
我建立表格的程式碼如下。
\caption{Common Curriculum}
\centering
\begin{tabularx}{0.9\linewidth}[ht]{||p{0.3\linewidth} | p{0.3\linewidth} | p{0.3\linewidth}||}
\hline
Physical Concepts & Mathematical Skills and Notation & Application in Quantum Information \\
\hline\hline
1 & 6 & 87837 \\
\hline
2 & 7 & 78 \\
\hline
3 & 545 & 778 \\
\hline
4 & 545 & 18744 \\
\hline
5 & 88 & 788 \\
\hline
\end{tabularx}
\label{tab:CommonCurr}.
\end{table}
我嘗試過使用{\textwidth}
而不是{0.9\linewidth}
.我也嘗試過使用文字寬度的三分之一,但我認為這個想法的問題是由於四捨五入造成的,因為我的水平線然後延伸到表格之外,給了我一個相反的問題。
任何幫助,將不勝感激!
答案1
我想知道是否可能喜歡下面的表格:
上面的“專業外觀”表的 Az 編寫使用了tabularray
帶有庫的包(加載同名的包)和一個更窄的表:
\documentclass{article}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\begin{table}[ht]
\caption{Common Curriculum}
\label{tab:CommonCurr}
\centering
\begin{tblr}{width=0.75\linewidth,
colspec = {X[c]
X[c, si={table-format=3.0}]
X[c, si={table-format=5.0}]},
row{even} = {belowsep=-2pt},
row{1} = {guard, c}
}
\toprule
{Physical\\ Concepts}
& Mathematical Skills and Notation
& Application in Quantum Information \\
\midrule
1 & 6 & 87837 \\
2 & 7 & 78 \\
3 & 545 & 778 \\
4 & 545 & 18744 \\
5 & 88 & 788 \\
\bottomrule
\end{tblr}
\end{table}
\end{document}
但是,如果您喜歡問題中顯示的水平線和垂直線“監獄”中的每個單元格,那麼 MWE 是:
\documentclass{article}
\usepackage[skip=0.33\baselineskip]{caption}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\begin{document}
\begin{table}[ht]
\caption{Common Curriculum}
\label{tab:CommonCurr}
\centering
\begin{tblr}{width=0.75\linewidth,
hlines, vlines,
colspec = {X[c]
X[c, si={table-format=3.0}]
X[c, si={table-format=5.0}]},
row{1} = {guard, c}
}
{Physical\\ Concepts}
& Mathematical Skills and Notation
& Application in Quantum Information \\
1 & 6 & 87837 \\
2 & 7 & 78 \\
3 & 545 & 778 \\
4 & 545 & 18744 \\
5 & 88 & 788 \\
\end{tblr}
\end{table}
\end{document}
和表比: