5

I spent an inordinate amount of time creating 2 beautiful tables for a manuscript. Paper accepted!

Turns out the journal wants either Word or LaTeX, but not a mix, and the tables must be in the main text itself, not separate.

This leaves me with two options:

  1. Convert the tables to Word
  2. Rewrite the paper in LaTeX (still doing most writing in Word).

(2) Seemed to be the logical choice, and I was making progress until I realized my tables can't simply cut and paste into the LaTeX document. There are all sorts of clashing errors that are extremely unfriendly to newbies. They are also landscape (wide) tables, which isn't helping.

I tried (1) using pandoc, but I get absolute garbage - jibberish and missing 90% of the text.

Table Text as follows:

\documentclass[a4paper, landscape]{article} 
% Make Landscape
\usepackage[a4paper,margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{dcolumn} 
% dcolumn to line up decimals
\usepackage{booktabs,caption}
\captionsetup[table]{name=Table} 
\usepackage[flushleft]{threeparttable} 
% The above two to allow that last line with the dagger as a bottom note.
\usepackage{caption}
\captionsetup{skip=0pt}
% Eliminates the space between the caption and the table itself.

\begin{document}

\begin{table}[!htbp] \centering 
 \begin{threeparttable}
  \caption{Regression models linking number of pregnancies to telomere length (models 1-4) and DNAmAge (models 5-8).} 
  \label{table2} 
\begin{tabular}{
>{\bfseries}l
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
\\[-1.8ex] & \multicolumn{4}{c}{\textbf{Telomere Length~}} & \multicolumn{4}{c}{\textbf{DNAmAge~}} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)$^{\dagger}$} & \multicolumn{1}{c}{(3)$^{\dagger}$} & \multicolumn{1}{c}{(4)$^{\dagger}$} & \multicolumn{1}{c}{(5)} & \multicolumn{1}{c}{(6)$^{\dagger}$} & \multicolumn{1}{c}{(7)$^{\dagger}$} & \multicolumn{1}{c}{(8)$^{\dagger}$}\\ 
% You need the $ to 'leave' the text and get back to a command

\hline \\[-1.8ex] 

%%%%%%%%%

 Age & -0.047 & -0.029 & -0.028 & -0.029 & 0.485 & 0.667 & 0.656 & 0.645 \\ 
  & p = 0.003^{**} & p = 0.071^{+} & p = 0.073^{+} & p = 0.068^{+} & p = 0.293 & p = 0.157 & p = 0.158 & p = 0.165 \\ 
  No.Pregnancies & -0.014 & -0.013 & -0.014 & -0.016 & 0.363 & 0.326 & 0.459 & 0.510 \\ 
  & p = 0.025^{*} & p = 0.039^{*} & p = 0.031^{*} & p = 0.020^{*} & p = 0.026^{*} & p = 0.049^{*} & p = 0.007^{**} & p = 0.005^{**} \\ 
  SES &  & -0.006 & -0.006 & -0.004 &  & -0.180 & -0.214 & -0.291 \\ 
  &  & p = 0.143 & p = 0.161 & p = 0.395 &  & p = 0.146 & p = 0.081^{+} & p = 0.055^{+} \\ 
  Currently Pregnant (Y) &  &  & 0.011 & 0.011 &  &  & -1.472 & -1.460 \\ 
  &  &  & p = 0.534 & p = 0.540 &  &  & p = 0.001^{**} & p = 0.001^{**} \\ 
  No.Pregnancies x SES &  &  &  & -0.004 &  &  &  & 0.106 \\ 
  &  &  &  & p = 0.362 &  &  &  & p = 0.385 \\ 
  Intercept & 1.826 & 1.337 & 1.332 & 1.343 & 14.818 & 10.319 & 10.611 & 10.850 \\ 
  & p < 0.001^{**} & p < 0.001^{**} & p < 0.001^{**} & p < 0.001^{**} & p = 0.138 & p = 0.318 & p = 0.297 & p = 0.287 \\ 
 \hline \\[-1.8ex] 
\normalfont{Observations} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{397} & \multicolumn{1}{c}{397} & \multicolumn{1}{c}{397} & \multicolumn{1}{c}{397} \\ 
\normalfont{Adjusted R$^{2}$} & \multicolumn{1}{c}{0.015} & \multicolumn{1}{c}{0.063} & \multicolumn{1}{c}{0.062} & \multicolumn{1}{c}{0.062} & \multicolumn{1}{c}{0.011} & \multicolumn{1}{c}{0.041} & \multicolumn{1}{c}{0.067} & \multicolumn{1}{c}{0.067} \\ 

%%%%%%%%%%%%%%
\hline \\[-1.8ex]  
\end{tabular} 
    \begin{tablenotes}
      \small
      \item $^{\dagger}$Marked models include controls for top 10 principal components of genetic variation and average urbanicity-score (complete results in Supplementary Table S1).
      +p\textless{0.1};
      *p\textless0.05;
      **p\textless0.01;
      ***p\textless0.001 
    \end{tablenotes}
  \end{threeparttable}
\end{table}
\end{document}

Journal (Scientific Reports) Template here

Please help! I have been trying to transition to LaTeX (with R and RMarkdown) and convince others this is a good idea, but am seriously let down when I can't even embed a simple table into a pre-existing template!

  • 4
    i can compile your table without any problem, (no errors, no warnings, no bad boxes). however, i don't understand meaning of p = 0.031^{*}, since in notes you inform reader that * means *: p \textless 0.05 ... welcome to tex.se! – Zarko May 26 '18 at 21:16
  • Thanks for you kindness. It makes up for the pain of trying to learn! I also can compile the table. But I can't 'embed' it within the Journal Template. Or are you able to do this? – Calen May 26 '18 at 21:32
  • 1
    Simple Table: For me, tables are one of the toughest challenges with LaTeX :) – Dr. Manuel Kuehner May 26 '18 at 22:12
  • 2
    @Dr.ManuelKuehner - Actually, creating good and appealing tables tends to be a challenge in any typesetting system, not just LaTeX. – Mico May 26 '18 at 23:19
  • 2
    @Mico Maybe I have another Best-Of of LaTeX as you have, but I get your point. I just wanted to make the OP less sceptical about LaTeX. – Dr. Manuel Kuehner May 26 '18 at 23:36
2

I think you should aim to declutter the look of the table, say by moving the "p-value" reminders into the header column. Incidentally, don't bother showing the p-values of the intercept terms: Nobody cares whether these terms are significant or not.

Also, do provide more structure to the d columns; that'll tighten up the look of the table tremendously. I'd also remove all bold-facing: it doesn't actually help make the table more readable or understandable. Since you're loading the booktabs package anyway, you might as well (should?!) use its line-drawing macros instead of the generic-LaTeX \hline directive. And, since you're loading the threeparttable environment, why not also make use of the \tnote macro for the "dagger" markers in the second header row.

Off-topic: Is "urbanicity" a real word? Might "urbanization" work for you? In my view, the term "urbanicity" is particularly unfortunate as it contains the particles "urb[is]" and "city" -- two terms for, well, cities...

enter image description here

\documentclass[a4paper,landscape]{wlscirep} % see https://github.com/SFICSSS16-CircularEconomy/Documents/blob/master
\usepackage[margin=1in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{dcolumn} % dcolumn to line up decimals
\newcolumntype{d}[1]{D..{#1}}

\usepackage{booktabs,caption}
\captionsetup[table]{name=Table} 
\captionsetup{skip=0pt}% no extra space below caption

\usepackage[flushleft]{threeparttable} 

\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro

\begin{document}

\begin{table}[!htbp] 
\centering 
\begin{threeparttable}
\caption{Regression models linking number of pregnancies to telomere length (models 1--4) and DNAmAge (models 5--8).} 
\label{table2} 

\begin{tabular}{@{} l *{8}{d{2.5}} @{}} % note: "d{2.5}", not "d{3}"
\toprule
& \multicolumn{4}{c}{Telomere Length} & \multicolumn{4}{c@{}}{DNAmAge} \\ 
\cmidrule(lr){2-5} \cmidrule(l){6-9}
& \mc{(1)} & \mc{(2)\tnote{$\dagger$}} & \mc{(3)\tnote{$\dagger$}} 
& \mc{(4)\tnote{$\dagger$}} & \mc{(5)} & \mc{(6)\tnote{$\dagger$}} 
& \mc{(7)\tnote{$\dagger$}} & \multicolumn{1}{c@{}}{(8)\tnote{$\dagger$}}\\ 

\midrule

Age & -0.047 & -0.029 & -0.028 & -0.029 & 0.485 & 0.667 & 0.656 & 0.645 \\ 
\quad$p$-values&0.003^{**} &0.071^{+} &0.073^{+} &0.068^{+} &0.293 &0.157 &0.158 &0.165 \\ \addlinespace
No.Pregnancies & -0.014 & -0.013 & -0.014 & -0.016 & 0.363 & 0.326 & 0.459 & 0.510 \\ 
\quad$p$-values&0.025^{*} &0.039^{*} &0.031^{*} &0.020^{*} &0.026^{*} &0.049^{*} &0.007^{**} &0.005^{**} \\ \addlinespace
SES &  & -0.006 & -0.006 & -0.004 &  & -0.180 & -0.214 & -0.291 \\ 
\quad$p$-values&  &0.143 &0.161 &0.395 &  &0.146 &0.081^{+} &0.055^{+} \\ \addlinespace
Currently Pregnant (Y) &  &  & 0.011 & 0.011 &  &  & -1.472 & -1.460 \\ 
\quad$p$-values&  &  &0.534 &0.540 &  &  &0.001^{**} &0.001^{**} \\ \addlinespace
No.Pregnancies $\times$ SES &  &  &  & -0.004 &  &  &  & 0.106 \\ 
\quad$p$-values&  &  &  &0.362 &  &  &  &0.385 \\ \addlinespace
Intercept & 1.826 & 1.337 & 1.332 & 1.343 & 14.818 & 10.319 & 10.611 & 10.850 \\ 
%% One usually doesn't show p-values for the intercept terms ...
%& p < 0.001^{**} & p < 0.001^{**} & p < 0.001^{**} & p < 0.001^{**} &0.138 &0.318 &0.297 &0.287 \\ 
\midrule

Observations & \mc{821} & \mc{821} & \mc{821} & \mc{821} & \mc{397} 
             & \mc{397} & \mc{397} & \multicolumn{1}{c@{}}{397} \\ 
Adjusted R$^{2}$ & \mc{0.015} & \mc{0.063} & \mc{0.062} & \mc{0.062} 
     & \mc{0.011} & \mc{0.041} & \mc{0.067} & \multicolumn{1}{c@{}}{0.067} \\ 
\bottomrule 
\end{tabular} 
\begin{tablenotes}

\small
\item[$\dagger$]Marked models include controls for top 10 principal components of 
genetic variation and average urbanicity score (complete results in 
Supplementary Table S1).

$^{+}\ p<0.1$; $^{*}\ p<0.05$; $^{**}\ p<0.01$; $^{***}\ p<0.001$.
\end{tablenotes}
\end{threeparttable}
\end{table}
\end{document}
  • 1
    p.s. And yes, "Urbanicity" is a word. ;) – Calen May 27 '18 at 16:27
2

Here is the table embedded in the template. It fits perfectly well with a simple modification; instead of the p = scattered everywhere, put the p-value inside two parens (..). Also the @{} will give you some more space. You can even gain more space by combining all four instances of p < 0.001^{**} into one.

\documentclass[fleqn,10pt]{wlscirep}

\usepackage{dcolumn} 
% dcolumn to line up decimals
\usepackage{booktabs,caption}
\captionsetup[table]{name=Table} 
\usepackage[flushleft]{threeparttable} 
% The above two to allow that last line with the dagger as a bottom note.
\usepackage{caption}
\captionsetup{skip=0pt}

\title{Scientific Reports Title to see here (20 words or less)}
\author[1,*]{Alice Author}
\author[2]{Bob Author}
\author[1,2,+]{Christine Author}
\author[2,+]{Derek Author}
\affil[1]{Affiliation, department, city, postcode, country}
\affil[2]{Affiliation, department, city, postcode, country}
\affil[*]{corresponding.author@email.example}
\affil[+]{these authors contributed equally to this work}

%\keywords{Keyword1, Keyword2, Keyword3}
\begin{abstract}
...
\end{abstract}

\end{abstract}
\begin{document}

\flushbottom
\maketitle
\thispagestyle{empty}

\noindent Please note: Abbreviations should be introduced at the first mention in the main text – no abbreviations lists. Suggested structure of main text (not enforced) is provided below.

\section*{Introduction}

The Introduction section, of referenced text\cite{Figueredo:2009dg} expands on the background of the work (some overlap with the Abstract is acceptable). The introduction should not include subheadings.

\begin{table}[!htb] \centering 
 \begin{threeparttable}
  \caption{Regression models linking number of pregnancies to telomere length (models 1-4) and DNAmAge (models 5-8).} 
  \label{table2} 
\begin{tabular}{@{}
>{\bfseries}l
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} 
D{.}{.}{3} } 
\\[-1.8ex]\hline 
\hline \\[-1.8ex] 
\\[-1.8ex] & \multicolumn{4}{c}{\textbf{Telomere Length~}} & \multicolumn{4}{c}{\textbf{DNAmAge~}} \\ 
\\[-1.8ex] & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)$^{\dagger}$} & \multicolumn{1}{c}{(3)$^{\dagger}$} & \multicolumn{1}{c}{(4)$^{\dagger}$} & \multicolumn{1}{c}{(5)} & \multicolumn{1}{c}{(6)$^{\dagger}$} & \multicolumn{1}{c}{(7)$^{\dagger}$} & \multicolumn{1}{c}{(8)$^{\dagger}$}\\ 
% You need the $ to 'leave' the text and get back to a command
\hline \\[-1.8ex] 
%%%%%%%%%
 Age & -0.047 & -0.029 & -0.028 & -0.029 & 0.485 & 0.667 & 0.656 & 0.645 \\ 
  & (0.003)^{**} & (0.071)^{+} & (0.073)^{+} & (0.068)^{+} & (0.293) & (0.157) & (0.158) & (0.165) \\ 
  No. Pregnancies & -0.014 & -0.013 & -0.014 & -0.016 & 0.363 & 0.326 & 0.459 & 0.510 \\ 
  & (0.025)^{*} & (0.039)^{*} & (0.031)^{*} & (0.020)^{*} & (0.026)^{*} & (0.049)^{*} & (0.007)^{**} & (0.005)^{**} \\ 
  SES &  & -0.006 & -0.006 & -0.004 &  & -0.180 & -0.214 & -0.291 \\ 
  &  & (0.143) & (0.161) & (0.395) &  & (0.146) & (0.081)^{+} & (0.055)^{+} \\ 
  Currently Pregnant (Y) &  &  & 0.011 & 0.011 &  &  & -1.472 & -1.460 \\ 
  &  &  & (0.534) & (0.540) &  &  & (0.001)^{**} & (0.001)^{**} \\ 
  No. Pregnancies x SES &  &  &  & -0.004 &  &  &  & 0.106 \\ 
  &  &  &  & (0.362) &  &  &  & (0.385) \\ 
  Intercept & 1.826 & 1.337 & 1.332 & 1.343 & 14.818 & 10.319 & 10.611 & 10.850 \\ 
  & p < 0.001^{**} & p < 0.001^{**} & p < 0.001^{**} & p < 0.001^{**} & (0.138) & (0.318) & (0.297) & (0.287) \\ 
 \hline \\[-1.8ex] 
\normalfont{Observations} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{821} & \multicolumn{1}{c}{397} & \multicolumn{1}{c}{397} & \multicolumn{1}{c}{397} & \multicolumn{1}{c}{397} \\ 
\normalfont{Adjusted R$^{2}$} & \multicolumn{1}{c}{0.015} & \multicolumn{1}{c}{0.063} & \multicolumn{1}{c}{0.062} & \multicolumn{1}{c}{0.062} & \multicolumn{1}{c}{0.011} & \multicolumn{1}{c}{0.041} & \multicolumn{1}{c}{0.067} & \multicolumn{1}{c}{0.067} \\ 
%%%%%%%%%%%%%%
\hline \\[-1.8ex]  
\end{tabular} 
    \begin{tablenotes}
      \small
      \item$^{\dagger}$Marked models include controls for top 10 principal components of genetic variation and average urbanicity-score (complete results in Supplementary Table S1).
      +p\textless{0.1};
      *p\textless0.05;
      **p\textless0.01;
      ***p\textless0.001 
    \end{tablenotes}
  \end{threeparttable}
\end{table}

\end{document}

enter image description here

  • I can't test this right this second but thanks already for your help and if this works, double thanks! Tex community is fast and helpful AND kind?! Yes! – Calen May 26 '18 at 22:11
  • p.s. Sorry I can't upvote I don't have the reputation. – Calen May 26 '18 at 22:12
  • With the setting D{.}{.}{3}, the column contents aren't centered all that well. This may be seen in how (1), (2), etc are placed in the column headers. Better to specify D{.}{.}{2.5}. And, consider writing *{8}{D{.}{.}{<whatever>} instead of having 8 separate D statements. – Mico May 27 '18 at 6:31
2

edit: please apology me for disturbances at uploading my answer. i first time use overleaf and have unexpected problems :-(

now seems that i succeed to manage them :-)

enter image description here

similarly as AboAmmar i suggest to change unusual notation for p values (see my comment below question). other suggestion is mostly off-topic, however, it can help you in at your other tables design:

  • for instead of \hlines are used rules from package booktabs
  • removed are all \\[-1.8ex] as unnecessary clutter (rules from booktabs better manage vertical spaces between rows)
  • introduced are two \newcommands for shorter writing code in table
  • code for content of table already in editor mimic final view of table (on this way you can more easy navigate through your table

\documentclass[fleqn,10pt]{wlscirep}
\usepackage[utf8]{inputenc}

\usepackage{booktabs}       % for nice rules in table
\usepackage{dcolumn}        % dcolumn to line up decimals
\usepackage[flushleft]{threeparttable}
\newcommand\mcbf[1]{\multicolumn{1}{c}{\textbf{#1}}}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}

\usepackage{caption}
\captionsetup{skip=0ex}

\usepackage{lipsum}         % for dummy text

\begin{document}
\lipsum[1]
\begin{table}[htbp]
\centering
\setlength\tabcolsep{0pt}
    \begin{threeparttable}
\caption{Regression models linking number of pregnancies to telomere length (models 1-4) and DNAmAge (models 5-8).}
  \label{table2}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
    >{\bfseries}l
    *{8}{D{.}{.}{5}}
                }
%%%% column headers
    \toprule
    & \multicolumn{4}{c}{\textbf{Telomere Length~}} & \multicolumn{4}{c}{\textbf{DNAmAge~}} \\
    \cmidrule(lr){2-5}
    \cmidrule(l){6-9}
    & \mcbf{(1)}                & \mcbf{(2)$)^{\dagger}$}   & \mcbf{(3)$)^{\dagger}$}
    & \mcbf{(4)$^{\dagger}$}    & \mcbf{(5)}                & \mcbf{(6)$^{\dagger}$}
    & \mcbf{(7)$^{\dagger}$}    & \mcbf{(8)$^{\dagger}$}                                    \\
    \midrule
%%%% table body
 Age    & -0.047        & -0.029        & -0.028        & -0.029
        & 0.485         & 0.667         & 0.656         & 0.645                             \\
        & (0.003)^{**}  & (0.071)^{+}   & (0.073)^{+}   & (0.068)^{+}
        & (0.293        & (0.157        & (0.158        & (0.165                            \\
No.Pregnancies
        & -0.014        & -0.013        & -0.014        & -0.016
        & 0.363         & 0.326         & 0.459         & 0.510                             \\
        & (0.025)^{*}   & (0.039)^{*}   & (0.031)^{*}   & (0.020)^{*}
        & (0.026)^{*}   & (0.049)^{*}   & (0.007)^{**}  & (0.005)^{**}                      \\
SES     &               & -0.006        & -0.006        & -0.004
        &               & -0.180        & -0.214        & -0.291                            \\
        &               & (0.143        & (0.161        & (0.395
        &               & (0.146        & (0.081)^{+}   & (0.055)^{+}                       \\
Currently Pregnant (Y)
        &               &               & 0.011         & 0.011
        &               &               & -1.472        & -1.460                            \\
        &               &               & (0.534        & (0.540
        &               &               & (0.001)^{**}  & (0.001)^{**}                      \\
No.Pregnancies x SES
        &               &               &               & -0.004
        &               &               &               & 0.106                             \\
        &               &               &               & (0.362
        &               &               &               & (0.385                            \\
Intercept & 1.826         & 1.337         & 1.332         & 1.343
        & 14.818        & 10.319        & 10.611        & 10.850                            \\
        & p < 0.001     & p < 0.001     & p < 0.001     &  p < 0.001
        & (0.138)       & (0.318)       & (0.297)       & (0.287)                           \\
    \midrule
\normalfont Observations
        & \mc{821}      & \mc{821}      & \mc{821}          & \mc{821}
        & \mc{397}      & \mc{397}      & \mc{397}          & \mc{397}                      \\
\normalfont Adjusted R$)^{2}$
        & \mc{0.015}    & \mc{0.063}    & \mc{0.062}        & \mc{0.062}
        & \mc{0.011}    & \mc{0.041}    & \mc{0.067}        & \mc{0.067}                    \\
    \bottomrule
\end{tabular*}
%%%% table notes

    \begin{tablenotes}[para]\small
\item[$^{\dagger}$] Marked models include controls for top 10 principal components of genetic variation and average urbanicity-score (complete results in Supplementary Table S1).

\item[+]    $p < 0.1$;
\item[*]    $p < 0.05$;
\item[**]   $p < 0.01$;
\item[***]  $p < 0.001$.
    \end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.