2

I need to stack three sideway tables. My code makes Latex remove the captions somehow. It reports floatrow error, caption(s) lost. Is there also a way to align all three tables to the bottom of the page? Thanks in advance!

output result

\documentclass[A4, 11pt]{report}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{floatrow}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{amsmath}
\usepackage{url}
\usepackage[labelfont=bf]{caption}
\usepackage{indentfirst}
\usepackage{pdfpages}
\usepackage{tikz}
\usepackage{rotating}

\floatsetup[table]{capposition=top}
\graphicspath{{graphics/}}
\let\origref\ref
\def\ref#1{\textbf{\origref{#1}}}

\begin{document}
\begin{sidewaystable}[!h]
\footnotesize
\caption{Sample A, B and C calculations}

\begin{tabular}{p{3cm}p{1.5cm}p{1cm}p{1.5cm}p{1cm}p{1.5cm}p{1cm}} 
\hline\hline
\rule{0pt}{3ex}
\textbf{Compound} & \textbf{Sample A (area)} & \textbf{\% A} & \textbf{Sample B (area)} & \textbf{\% B} & \textbf{Sample C (area)} & \textbf{\% C} \\[0.5ex]
\midrule
Benzene & 97166 & 29.796 & 118538 & 28.804 & 73071 & 34.719 \\
Chlorobenzene & 79837 & 24.482 & 101977 & 24.780 & 52619 & 25.002 \\
1,2-dichlorobenzene & 86195 & 26.432 & 111483 & 27.090 & 50634 & 24.058 \\
Trichlorobenzene & 62905 & 19.290 & 79534 & 19.326 & 34138 & 16.221 \\
\bottomrule
\end{tabular}%

\vspace{2.5\baselineskip}
\caption{Unknown 1, 2 and 3 calculations}
\begin{tabular}{p{3cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
\hline\hline
\rule{0pt}{3ex}
\textbf{Compound} & \textbf{Unk 1 area} & \textbf{Unk 1 area \% } & \textbf{Unk 2 area} & \textbf{Unk 2 area \% } & \textbf{Unk 3 area} & \textbf{Unk 3 area \% } \\[0.5ex]
\midrule
Benzene & 37439 & 13.666 & 44157 & 13.076 & 46672 & 12.987 \\
Chlorobenzene & 68335 & 24.943 & 83331 & 24.676 & 88155 & 24.531 \\
1,2-dichlorobenzene & 80497 & 29.382 & 100331 & 29.710 & 107083 & 29.798 \\
Trichlorobenzene & 87692 & 32.009 & 109881 & 32.538 & 117455 & 32.684 \\
\bottomrule
\end{tabular}%

\vspace{2.5\baselineskip}
\caption{Unknown 1, 2 and 3 calculations}
\begin{tabular}{p{3cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}p{1.5cm}}
\hline\hline
\rule{0pt}{3ex}
\textbf{Compound} & \textbf{Unk 1 Corr. Area} & \textbf{Unk 1 \% Comp.} & \textbf{Unk 2 Corr. Area} & \textbf{Unk 2 \% Comp.} & \textbf{Unk 3 Corr. Area} & \textbf{Unk 3 \% Comp.} \\[0.5ex]
\midrule
Benzene & 29957 & 10.118 & 35333 & 9.654 & 37345 & 9.583 \\
Chlorobenzene & 65929 & 22.268 & 80397 & 21.968 & 85051 & 21.824 \\
1,2-dichlorobenzene & 87726 & 29.630 & 109342 & 29.876 & 116700 & 29.945 \\
Trichlorobenzene & 112455 & 37.983 & 140910 & 38.502 & 150623 & 38.649 \\
\bottomrule
\end{tabular}%

\end{sidewaystable}
\end{document}
2

It would appear to be the case that the floatrow package's code interacts in undesirable ways with that of the rotating package. Since it doesn't look like the floatrow package is truly needed, I wouldn't use it.

I would take care to structure the tables' headers so that they have a consistent look while avoiding line breaks in unfortunate places. Making sure that the three tables have (at least roughly) the same width also seems desirable.

enter image description here

\documentclass[A4, 11pt]{report}
\usepackage{booktabs,siunitx,rotating,array}
\sisetup{group-digits=false}
%\usepackage{floatrow}
%\floatsetup[table]{capposition=top}
\usepackage[labelfont=bf]{caption}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\begin{document}
\begin{sidewaystable}
\small
\centering

\caption{Sample A, B and C calculations}
\begin{tabular}{@{} l 
     S[table-format=5.0] C{1.55cm} 
     S[table-format=6.0] C{1.55cm}
     S[table-format=5.0] C{1.55cm} @{}} 
\hline\hline
\rule{0pt}{3.5ex}%
\textbf{Compound} & 
\multicolumn{1}{C{1.85cm}}{\textbf{Sample~A (area)}} & \textbf{\% A} & 
\multicolumn{1}{C{1.85cm}}{\textbf{Sample~B (area)}} & \textbf{\% B} & 
\multicolumn{1}{C{1.85cm}}{\textbf{Sample~C (area)}} & \textbf{\% C} \\ \addlinespace
\midrule
Benzene & 97166 & 29.796 & 118538 & 28.804 & 73071 & 34.719 \\
Chlorobenzene & 79837 & 24.482 & 101977 & 24.780 & 52619 & 25.002 \\
1,2-dichlorobenzene & 86195 & 26.432 & 111483 & 27.090 & 50634 & 24.058 \\
Trichlorobenzene & 62905 & 19.290 & 79534 & 19.326 & 34138 & 16.221 \\
\bottomrule
\end{tabular}%

\vspace{2.5\baselineskip}
\caption{Unknown 1, 2 and 3 calculations}
\begin{tabular}{@{} l 
            S[table-format=5.0] C{1.7cm}
       *{2}{S[table-format=6.0] C{1.7cm}} @{}}
\hline\hline
\rule{0pt}{3.5ex}%
\textbf{Compound} & 
\multicolumn{1}{C{1.7cm}}{\textbf{Unk~1 area}} & \textbf{Unk~1 area \% } & 
\multicolumn{1}{C{1.7cm}}{\textbf{Unk~2 area}} & \textbf{Unk~2 area \% } & 
\multicolumn{1}{C{1.7cm}}{\textbf{Unk~3 area}} & \textbf{Unk~3 area \% } \\ \addlinespace
\midrule
Benzene & 37439 & 13.666 & 44157 & 13.076 & 46672 & 12.987 \\
Chlorobenzene & 68335 & 24.943 & 83331 & 24.676 & 88155 & 24.531 \\
1,2-dichlorobenzene & 80497 & 29.382 & 100331 & 29.710 & 107083 & 29.798 \\
Trichlorobenzene & 87692 & 32.009 & 109881 & 32.538 & 117455 & 32.684 \\
\bottomrule
\end{tabular}%

\vspace{2.5\baselineskip}
\caption{Unknown 1, 2 and 3 calculations}
\begin{tabular}{@{} l 
               *{3}{S[table-format=6.0]S[table-format=2.3]} @{}}
\hline\hline
\rule{0pt}{3ex}%
\textbf{Compound} & 
\multicolumn{1}{C{1.6cm}}{\textbf{Unk~1 Corr.\ Area}} & \multicolumn{1}{C{1.8cm}}{\textbf{Unk~1 \%~Comp.}} & 
\multicolumn{1}{C{1.6cm}}{\textbf{Unk~2 Corr.\ Area}} & \multicolumn{1}{C{1.8cm}}{\textbf{Unk~2 \%~Comp.}} & 
\multicolumn{1}{C{1.6cm}}{\textbf{Unk~3 Corr.\ Area}} & \multicolumn{1}{C{1.8cm}}{\textbf{Unk~3 \%~Comp.}} \\ \addlinespace
\midrule
Benzene & 29957 & 10.118 & 35333 & 9.654 & 37345 & 9.583 \\
Chlorobenzene & 65929 & 22.268 & 80397 & 21.968 & 85051 & 21.824 \\
1,2-dichlorobenzene & 87726 & 29.630 & 109342 & 29.876 & 116700 & 29.945 \\
Trichlorobenzene & 112455 & 37.983 & 140910 & 38.502 & 150623 & 38.649 \\
\bottomrule
\end{tabular}%

\end{sidewaystable}
\end{document}

Addendum to explain some of the coding choices:

  • \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}.

    \newcolumntype is a macro provided by the array package. Its use case is to create a new "column type" for use in tabular, array, and other table-like structures. Here, it is used to create a version of the basic p column type that centers the material rather than typesetting it fully justified.

  • \begin{tabular}{@{} l *{3}{S[table-format=6.0]S[table-format=2.3]} @{}}

    Since the entries in the numeric columns are numeric, IMO it's a good idea to align them on their (present or implied) decimal marker. The S column type, provided by the siunitx package, performs such formatting. The option table-format=6.0 informs LaTeX to set aside enough space for six digits before the (implied) decimal marker, and zero digits after the marker.

    The construct *{3}{...} informs LaTeX that there should be three instances of whatever is contained in .... To give another example, writing

    \begin{tabular}{*{10}{c}}
    

    is easier to read and debug than \begin{tabular}{cccccccccc} is, right?

    The @{} directives tell LaTeX not to provide any whitespace to the left of the first column or to the right of the final column.

  • thanks for modifying it; it looks great. Would you please explain what the \begin{tabular}{@{} l *{3}{S[table-format=6.0]S[table-format=2.3]} @{}} and \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}} does? I am not familiar with this. thanks again. – Spencer Trinh Jul 1 '15 at 10:53

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.