
\begin{table}[h]
\centering
\caption{Minimum Deviation ${D}_m$ from ${R}_1$}
\begin{tabular}{|c|>{$}c<{$}|}
\hline
Color & \text{Angle ($^\circ$)} \\ \hline
Red Medium & 48.17 \pm 0.25 \\ \hline
Yellow & 49.19 \pm 0.25 \\ \hline
Blue cyan weak & 50.16 \pm 0.25 \\ \hline
Blue cyan strong & 50.27 \pm 0.25 \\ \hline
Blue medium & 50.52 \pm 0.25 \\ \hline
Violet & 51.10 \pm 0.25 \\
\hline
\end{tabular}
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%
我首先開始只使用 來編寫表格,\begin{tabular}
但我被告知它需要在表格環境內,這就是原因,\begin{table}
但我不明白為什麼我不能只使用 來編寫表格,\begin{tabular}
因為儘管我有我想要的表格的錯誤。我將來會遇到嚴重的問題嗎?這是什麼{|c|>{$}c<{$}|}
意思?我知道如果我放的話,\begin{tabular}{|c|c|c|}
我會得到帶有垂直線的列。當我把|r|
它放在根本不起作用的時候!這個符號$
我不知道它是什麼!
答案1
tabular
table
只有當您希望table
能夠漂浮在文件中時才需要位於環境中。如果您希望表格準確地放置在您放置的位置,那麼您table
根本不需要使用環境。
這{|c|>{$}c<{$}|}
使得第二列自動處於數學模式。這就是為什麼您需要\text
並且可以說48.17 \pm 0.25
而不是$48.17 \pm 0.25$
,如果您希望在文檔中的其他地方(第二列之外)將此數學文本添加到您的文檔中,則需要使用 。
另外,我認為桌子看起來更好booktabs
包裹。這是您的表的比較:
和版本(我將第一列也booktabs
更改為ef 對齊):l
筆記:
代碼:
\documentclass{article}
\usepackage{ams math}% Needed for \text
\usepackage{array}% For tabluar specification
\usepackage{caption}
\usepackage{booktabs}
\begin{document}
{\centering
\captionof{table}{Minimum Deviation ${D}_m$ from ${R}_1$}
\begin{tabular}{|c|>{$}c<{$}|}
\hline
Color & \text{Angle ($^\circ$)} \\ \hline
Red Medium & 48.17 \pm 0.25 \\ \hline
Yellow & 49.19 \pm 0.25 \\ \hline
Blue cyan weak & 50.16 \pm 0.25 \\ \hline
Blue cyan strong & 50.27 \pm 0.25 \\ \hline
Blue medium & 50.52 \pm 0.25 \\ \hline
Violet & 51.10 \pm 0.25 \\
\hline
\end{tabular}\par}
\par\bigskip\noindent
With the \verb|booktabs| package:
{\centering
\captionof{table}{Minimum Deviation ${D}_m$ from ${R}_1$}
\begin{tabular}{l >{$}c<{$}}\toprule
Color & \text{Angle ($^\circ$)} \\
\cmidrule(lr){1-1}
\cmidrule(lr){2-2}
Red Medium & 48.17 \pm 0.25 \\
Yellow & 49.19 \pm 0.25 \\
Blue cyan weak & 50.16 \pm 0.25 \\
Blue cyan strong & 50.27 \pm 0.25 \\
Blue medium & 50.52 \pm 0.25 \\
Violet & 51.10 \pm 0.25 \\
\bottomrule
\end{tabular}\par}
\end{document}