-1

I am trying to create a table, which has four columns, but somewhat what the table has ugly looking.

\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}

If you create this table, you will see the part

\textrm{$\frac{Y(\theta)}{Y(0)}$ $\pm \sigma$ $\frac{Y(\theta)}{Y(0)}$ } 

is in different place. Can you help me?

I really appreciate your support.

Mico
  • 506,678
Bora
  • 39
  • 2
    I your question you mention 4 columns, but you only specify 3 columns. There must be an error message such as Extra alignment tab has been changed to \cr. Therefore add a fourth column specifier (for example \begin{tabular}{lcrr} or something else depending on the desired horizontal alignment. You will also have to add \\ in order to start a new row. – leandriis Dec 06 '19 at 20:45

3 Answers3

4

Your code, as posted, has two severe problems and quite a few less severe problems.

  • There's an \end{table} statement but no \begin{table} statement.

  • The declaration \begin{tabular}{lcr} cannot be correct since it sets up only three columns, whereas the table's header alone features for columns. I suggest you employ \begin{tabular}{lccc}.

  • The line

    \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)}$ }\\
    

    features no fewer than four [4!] utterly unnecessary \textrm wrappers. Get rid of them.

  • The document class option doublecolumn isn't used. In fact, could it be a mistake? Should you maybe be using the option twocolumn?

  • If you're concerned about the table being ugly, you should consider (a) getting rid of the preprint option and (b) not using the ruledtabular environment and the \colrule macro. Instead, load the booktabs package and learn how to use \toprule, \midrule, and \bottomrule. And switch to from a tabular to an array environment save having to type lots and lots and lots of $ symbols.

enter image description here

\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}
Mico
  • 506,678
2

To big to be placed in a comment :-)

I'm guessing that you looking for something like this:

enter image description here

(most of numbers in the table are dummy)

Your code has many issues and serious errors (see Mico answer). To make yourself more familiar with writing table, see some introductory text as is for example LaTeX/Tables.

For above shoved table the MWE is:

\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}

It can serve as starting point in your effort to rewrite of your table. Since all cells are in math mode, for table I use array which is encapsulated in equation environment.

Zarko
  • 296,517
1

Following the MWE by Zarko, but with siunitx and in text mode (sort of):

\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}

See also this for \tabcolsep.

screenshot