
我正在嘗試創建一個有四列的表,但該表看起來有些難看。
\documentclass[%
preprint,
doublecolumn
%superscriptaddress,
%groupedaddress,
%unsortedaddress,
%runinaddress,
%frontmatterverbose,
%preprint
%preprintnumbers,
%nofootinbib,
%nobibnotes,
%bibnotes,
amsmath,amssymb,
aps,
%pra,
prc,
%rmp,
%prstab,
%prstper,
%floatfix,
]{revtex4-2}
\usepackage{anyfontsize}
\usepackage{float}
\usepackage{mathtools, nccmath}
\usepackage{graphicx}% Include figure files
\usepackage{tabularx}
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
%\usepackage{hyperref}% add hypertext capabilities
\usepackage[mathlines]{lineno}% Enable numbering of text and display math
\usepackage{amsmath}
\linenumbers\relax % Commence numbering lines
%\usepackage{latexsym}
%\usepackage[showframe,%Uncomment any one of the following lines to test
%%scale=0.7, marginratio={1:1, 2:3}, ignoreall,% default settings
%%text={7in,10in},centering,
%%margin=1.5in,
%%total={6.5in,8.75in}, top=1.2in, left=0.9in, includefoot,
%%height=10in,a5paper,hmargin={3cm,0.8in},
%]{geometry}
\begin{document}
\begin{ruledtabular}
\begin{tabular}{lcr}
\textrm{$\theta$}& \textrm{$R(\theta)\pm \sigma R(\theta)$ }& \textrm{$Y(\theta) \pm \sigma {Y(\theta)}$} & \textrm{$\frac{Y(\theta)}{Y(0)}$ $\pm \sigma$ $\frac{Y(\theta)}{Y(0)}$ }\\
\colrule
0& 2.970$\pm$
10&2.774$\pm$
20&2.800$\pm$
30&2.526$\pm$
40&2.401$\pm$
50&2.399$\pm$
60&2.066$\pm$
70&2.174$\pm$
80&2.161$\pm$
90&2.091$\pm$
100&2.187$\pm$
110&2.272$\pm$
120&2.181$\pm$
\end{tabular}
\end{ruledtabular}
\end{table}
\end{document}
如果您建立此表,您將看到該部分
\textrm{$\frac{Y(\theta)}{Y(0)}$ $\pm \sigma$ $\frac{Y(\theta)}{Y(0)}$ }
是在不同的地方。你能幫助我嗎?
我非常感謝您的支持。
答案1
正如所發布的,您的程式碼有兩個嚴重的問題和一些不太嚴重的問題。
有
\end{table}
聲明但沒有\begin{table}
聲明。該聲明
\begin{tabular}{lcr}
不可能正確,因為它只設定了三列,而表頭單獨包含列。我建議你僱用\begin{tabular}{lccc}
.線路
\textrm{$\theta$}& \textrm{$R(\theta)\pm \sigma R(\theta)$ }& \textrm{$Y(\theta) \pm \sigma {Y(\theta)}$} & \textrm{$\frac{Y(\theta)}{Y(0)}$ $\pm \sigma$ $\frac{Y(\theta)}{Y(0)}$ }\\
具有不少於四個 [4!] 完全不必要的
\textrm
包裝器。擺脫他們。doublecolumn
不使用文檔類別選項。事實上,這可能是個錯誤嗎?您應該使用該選項嗎twocolumn
?如果您擔心表格難看,您應該考慮 (a) 刪除該
preprint
選項以及 (b) 不使用ruledtabular
環境和\colrule
巨集。相反,加載booktabs
包並學習如何使用\toprule
、\midrule
和\bottomrule
。並從tabular
到 環境切換array
,無需輸入大量$
符號。
\documentclass[%preprint,
twocolumn,
%doublecolumn -- does this option exist?!
amsmath,amssymb,aps,prc]{revtex4-2}
% I've omitted the entire remainder of your preamble
% since none of its instructions get used in this MWE
% (minimum working example).
\usepackage{booktabs} % for \toprule, \midrule, \bottomrule macros
\usepackage{siunitx} % for 'S' column type
\begin{document}
\begin{table}
\centering
$\begin{array}{@{} S[table-format=3.0] ccc @{}}
\toprule
{\theta} &
R(\theta)\pm \sigma R(\theta) &
Y(\theta) \pm \sigma Y(\theta) &
\frac{Y(\theta)}{Y(0)}\pm\sigma \frac{Y(\theta)}{Y(0)}\\
\midrule
0 & 2.970\pm{}\\
10 & 2.774\pm{}\\
20 & 2.800\pm{}\\
30 & 2.526\pm{}\\
40 & 2.401\pm{}\\
50 & 2.399\pm{}\\
60 & 2.066\pm{}\\
70 & 2.174\pm{}\\
80 & 2.161\pm{}\\
90 & 2.091\pm{}\\
100 & 2.187\pm{}\\
110 & 2.272\pm{}\\
120 & 2.181\pm{}\\
\bottomrule
\end{array}$
\end{table}
\end{document}
答案2
太大了,無法放在評論中:-)
我猜你正在尋找這樣的東西:
(表中大部分數字均為虛擬數字)
您的程式碼有很多問題和嚴重錯誤(請參閱米科回答)。為了讓自己更熟悉寫字台,請參考一些介紹文字,例如乳膠/表格。
對於上面的推入表,MWE 是:
\documentclass[twocolumn]{revtex4-2}
\usepackage{nccmath, mathtools, amssymb}
\usepackage{array, makecell}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\[
\setcellgapes{3pt}
\makegapedcells
\begin{array}{rccc}
\colrule
\theta
& R(\theta) \pm \sigma R(\theta)
& Y(\theta) \pm \sigma {Y(\theta)}
& \mfrac{Y(\theta)}{Y(0)} \pm \sigma\mfrac{Y(\theta)}{Y(0)} \\
\colrule
0 & 2.970 \pm 123 & 2.970 \pm 123 & 2.970 \pm 123 \\
10 & 2.774 \pm 123 & 2.774 \pm 123 & 2.774 \pm 123 \\
\colrule
\end{array}
\]
\lipsum[2]
\end{document}
它可以作為您重寫表格的起點。由於所有單元格都處於數學模式,因此我使用array
封裝在方程式環境中的表。
答案3
繼扎科 MWE,但siunitx
在文字模式下(有點):
\documentclass{standalone}
\usepackage{nccmath, mathtools, amssymb}
\usepackage{array, booktabs, siunitx}
\usepackage{microtype}
\begin{document}
\sisetup{
separate-uncertainty,
table-format = 1.3(1),
}
%% don't forget to undo it:
\setlength{\tabcolsep}{12pt}
\begin{tabular}{rSSS[table-align-uncertainty = false]}
\midrule
0 & 2.970 \pm 123 & 2.970 \pm 123 & 2.970 \pm 123 \\
10 & 2.774 \pm 123 & 2.774 \pm 123 & 2.774 \pm 123 \\
\bottomrule
\end{tabular}
\end{document}
也可以看看這為了\tabcolsep
。