2

I learnt Latex last month and am trying to write a large document with it. I have managed the text and figures, but not tables. Although my table is centered, I would like my caption to begin along with the first cell of the table rather than the full left indent like a normal paragraph.

I also have many footnotes which pertain to the whole table rather than specific parts of the table. I tried using \tablefootnote, but no text seems to appear. Also, I don't want the numbers, just the text.

\documentclass[a4paper, oneside]{book}
\usepackage[left=35mm, right=15mm, top=20mm, bottom=15mm]{geometry}
\usepackage{setspace}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{float}
\usepackage{tabularx}
\usepackage{amssymb}
\usepackage{booktabs} % For \toprule, \midrule and \bottomrule
\usepackage{pgfplotstable} % Generates table from .csv
\usepackage{longtable}    %Allows multi-page tables
\usepackage{rotating}     %Allows for single page landscape using \sidewaystable{}
\usepackage{pdflscape}     %Allows for landscape
\usepackage{multirow}      %Allows for merging across rows
\usepackage{tablefootnote} 
\usepackage{footnote}

\begin{document}

\begin{table}[h!]
\begin{center}
\caption{Proximate phenolic and carbohydrate content}
\label{Table4}
 \begin{tabular}{c c c c c c c} 
 \toprule
 &\multicolumn{2}{c}{\textbf{Leaf}}& &\multicolumn{2}{c}{\textbf{Roots}}\\
\cline{2-3}\cline{5-6} 
 \textbf{Plant} & \textbf{Colour} & \textbf{Density} &  &\textbf{Colour} & \textbf{Density}\\
 \midrule
 Sample1&26.1$\pm$0.7$^{c}$ &172.3$\pm$9.0& & 25.5$\pm$6.8$^{b}$&83.7$\pm$4.5$^{a}$\\
 Sample2&53.9$\pm$2.0$^{d}$&129.5$\pm$3.2& &29.4$\pm$4.8$^{b}$&11.7$\pm$1.8\\
 Sample3&32.5$\pm$3.2$^{c}$&163.3$\pm$6.5& &96.8$\pm$18.1&64.4$\pm$1.3\\
 Sample4&54.2$\pm$2.3$^{d}$&82.6$\pm$7.5& &28.9$\pm$3.0$^{b}$&35.7$\pm$1.2\\
 Sample5&28.4$\pm$3.9$^{c}$&172.1$\pm$6.3& &26.9$\pm$5.1$^{b}$&78.8$\pm$2.8$^{a}$\\
 Sample6&50.0$\pm$2.0$^{d}$&112.3$\pm$5.3& &54.1$\pm$5.7&48.1$\pm$7.1\\
 \bottomrule
\end{tabular}
\end{center}
\footnotesize{Values expressed in \%(mg.mg$^{-1}$)}\\
\footnotesize{Values with same superscript are statistically similar (OW-ANOVA,p \textless 0.01)}\\
\footnotesize{NSP=Non-starch polysaccahride}
\end{table}

\end{document}

I tried to be clever, but didn't work for the second caption:

\begin{table}[h!]
\begin{center}
\caption{Proximate phenolic and carbohydrate content}
\label{Table4}
 \begin{tabular}{c c c c c c c} 
 \toprule
 &\multicolumn{2}{c}{\textbf{Leaf}}& &\multicolumn{2}{c}{\textbf{Roots}}\\
\cline{2-3}\cline{5-6} 
 \textbf{Plant} & \textbf{Colour} & \textbf{Density} &  &\textbf{Colour} & \textbf{Density}\\
 \midrule
 Sample1&26.1$\pm$0.7$^{c}$ &172.3$\pm$9.0& & 25.5$\pm$6.8$^{b}$&83.7$\pm$4.5$^{a}$\\
 Sample2&53.9$\pm$2.0$^{d}$&129.5$\pm$3.2& &29.4$\pm$4.8$^{b}$&11.7$\pm$1.8\\
 Sample3&32.5$\pm$3.2$^{c}$&163.3$\pm$6.5& &96.8$\pm$18.1&64.4$\pm$1.3\\
 Sample4&54.2$\pm$2.3$^{d}$&82.6$\pm$7.5& &28.9$\pm$3.0$^{b}$&35.7$\pm$1.2\\
 Sample5&28.4$\pm$3.9$^{c}$&172.1$\pm$6.3& &26.9$\pm$5.1$^{b}$&78.8$\pm$2.8$^{a}$\\
 Sample6&50.0$\pm$2.0$^{d}$&112.3$\pm$5.3& &54.1$\pm$5.7&48.1$\pm$7.1\\
 \bottomrule
\end{tabular}
\end{center}
\begin{tabular}
\footnotesize{Values expressed in \%(mg.mg$^{-1}$)}\\
\footnotesize{Values with same superscript are statistically similar (OW-ANOVA,p \textless 0.01)}\\
\footnotesize{NSP=Non-starch polysaccahride}
\end{tabular}
\end{table}

Would this solution work in landscape format? I have tables of that variety as well

4
  • 1
    Why not use the tablenotes environment from the threeparttable?. Table notes are displayed direclty underneath the table.
    – leandriis
    Jul 23, 2020 at 18:16
  • 1
    threeparttable also ensures the caption is as wide as the table.
    – leandriis
    Jul 23, 2020 at 18:17
  • Where are the footnotes/tablenotes that correspond to the superscript letters?
    – leandriis
    Jul 23, 2020 at 18:22
  • Out of curiosity: What kind of units is \%(mg.mg$^{-1}$ supposed to be? Is (mg.mg$^{-1} supposed to be equal to mg/mg?
    – leandriis
    Jul 23, 2020 at 18:37

1 Answer 1

2

Here is my suggestion using threeparttable for the tablenotes. The caption alignment is also done with threeparttable in combination with an appropriate captionsetup. In order to improve the alignment of the numbers in the table, I have added the siunitx package:

enter image description here

\documentclass[a4paper, oneside]{book}
\usepackage[left=35mm, right=15mm, top=20mm, bottom=15mm]{geometry}
\usepackage{setspace}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{float}
\usepackage{tabularx}
\usepackage{amssymb}
\usepackage{booktabs} % For \toprule, \midrule and \bottomrule
\usepackage{pgfplotstable} % Generates table from .csv
\usepackage{longtable}    %Allows multi-page tables
\usepackage{rotating}     %Allows for single page landscape using \sidewaystable{}
\usepackage{pdflscape}     %Allows for landscape
\usepackage{multirow}      %Allows for merging across rows
\usepackage{tablefootnote} 
\usepackage{footnote}

\usepackage{threeparttable}
\usepackage{caption}
\captionsetup{singlelinecheck=false}
\usepackage{siunitx}
\sisetup{input-uncertainty-signs=\pm, 
         separate-uncertainty=true}
        
\begin{document}

\begin{table}[h!]
\centering
\begin{threeparttable}
\caption{Proximate phenolic and carbohydrate content}
\label{Table4}
\sisetup{table-format=2.1(3), 
         table-space-text-post=\tnote{a}, 
         table-align-text-post=false}
 \begin{tabular}{l S S S S} 
 \toprule
 &\multicolumn{2}{c}{\textbf{Leaf}}& \multicolumn{2}{c}{\textbf{Roots}}\\
\cmidrule(r){2-3}\cmidrule(l){4-5} 
 {\textbf{Plant}} & {\textbf{Colour}} & {\textbf{Density}} & {\textbf{Colour}} & {\textbf{Density}}\\
 \midrule
 Sample1 & 26.1 \pm 0.7\tnote{c} & 172.3 \pm 9.0 & 25.5 \pm 6.8\tnote{b} & 83.7 \pm 4.5\tnote{a} \\
 Sample2 & 53.9 \pm 2.0\tnote{d} & 129.5 \pm 3.2 & 29.4 \pm 4.8\tnote{b} & 11.7 \pm 1.8          \\
 Sample3 & 32.5 \pm 3.2\tnote{c} & 163.3 \pm 6.5 & 96.8 \pm 18.1         & 64.4 \pm 1.3          \\
 Sample4 & 54.2 \pm 2.3\tnote{d} & 82.6  \pm 7.5 & 28.9 \pm 3.0\tnote{b} & 35.7 \pm 1.2          \\
 Sample5 & 28.4 \pm 3.9\tnote{c} & 172.1 \pm 6.3 & 26.9 \pm 5.1\tnote{b} & 78.8 \pm 2.8\tnote{a} \\
 Sample6 & 50.0 \pm 2.0\tnote{d} & 112.3 \pm 5.3 & 54.1 \pm 5.7          & 48.1 \pm 7.1          \\
 \bottomrule
\end{tabular}
\footnotesize
Values expressed in \%(mg.mg$^{-1}$)

Values with same superscript are statistically similar (OW-ANOVA,p \textless 0.01)
 
NSP=Non-starch polysaccharide
\end{threeparttable}
\end{table}



\end{document}
2
  • @Mico: That would have been too obvious... Thanks for pointing it out, this is indeed easier. I have edited my answer accordingly.
    – leandriis
    Jul 23, 2020 at 18:44
  • 1
    I literally learn some LaTex last month and basically writing up my thesis now! Thanks a lot
    – Miloop
    Jul 23, 2020 at 19:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .