3

I have this code:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm]{geometry} % showframe
\usepackage{lipsum}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}

\captionsetup[table]{
    font=bf,
    size=normalsize,
    justification=centerlast,
    labelsep=newline
    }
\renewcommand\thetable{\Roman{table}}

\begin{document}
\lipsum[1-8]
\def\arraystretch{1.5}
\begin{table}[ht]
\centering
\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2, group-separator={,}, group-minimum-digits=4}
\caption{\large{Fancy Header}}
\label{table:fundsummary}
\parbox{\linewidth}{\small{This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes.}\vspace{2ex}}
\medskip\small\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                l
                S[table-format=-2.2]
           *{6}{S}
                }
\toprule
\multicolumn{1}{c}{\multirow{2}{*}{Description}}&
\multicolumn{1}{c}{\multirow{2}{*}{Variable}}&
\multicolumn{5}{c}{Averages}\\\cmidrule{3-7}
\multicolumn{2}{c}{}&{Factor 1}&{Factor 2}&{Factor 3}&{Factor 4}&{Factor 5}\\\midrule
Section 1       &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Section 2\\
Section 2.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 2.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 2.4     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Section 3\\
Section 3.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 3.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 3.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Section 4\\
Section 4.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 4.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 4.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\\midrule
Section 5\\
Section 5.1     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 5.2     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
Section 5.3     &11.11 &22.22 &33.33   &44.44   &55.55  &66.66\\
\bottomrule
\end{tabular*}
\end{table}
\lipsum[1-8]
\end{document}

which produces this output:

Table

For all the tables in my report that does not fill an entire page, I have that they appear at the top of a new page. I switch between tp and ht, at \begin{table}[], which works for all my other tables. But for some reason, it does not work here. When I use ht, as in the this example, it places the table at the bottom of the page. If I use tp, it places the table all by itself on a new page.

I apologize if this question is way too simple, but I have yet to figure out how to solve it. Thanks in advance!

  • 4
    Just change \begin{table}[ht] to \begin{table}[t]. ht means "here if possible, otherwise at the top". In this case, it is possible to put "here", so it does. t means "at the top" only. Furthermore, it would be better if you used p to insert in a "float page" too: \begin{table}[tp]. – Phelype Oleinik May 24 '18 at 18:18
2

your problem is solved by Phelype Oleinik comment, this answer is focused on off topic issues:

  • however since you load the package tabularx it can be exploited in table design (which gives according to my taste nicer result).
  • you define eight columns in table but use only seven:

\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[margin=2.5cm]{geometry} % showframe
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}
\newcommand\mcx[1]{\multicolumn{1}{>{\centering\arraybackslash}X}{#1}}
\usepackage{siunitx}
\usepackage[skip=0.33\baselineskip]{caption}

\captionsetup[table]{
    font=bf,
    size=normalsize,
    justification=centerlast,
    labelsep=newline
    }
\renewcommand\thetable{\Roman{table}}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%


\begin{document}
\lipsum[1]
\begin{table}[tp]                       % <--- considered Phelype Oleinik's comments
\renewcommand\arraystretch{1.1}
\centering
%\setlength\tabcolsep{0pt}
\sisetup{table-format=2.2,
         group-separator={,},
         group-minimum-digits=4
         }
\caption{\large{Fancy Header}}
\label{table:fundsummary}
\parbox{\linewidth}{\small
This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes. This table presents some very interesting and very fancy data, which I expect will provide me with at least two Nobel prizes.}

\medskip
%\small
\begin{tabularx}{\linewidth}{
                l
                S[table-format=-2.2]
           *{5}{S}                  % <--- changed
                }
    \toprule
\multirow{2}{*}[-0.5ex]{Description}
    & {\multirow{2}{*}[-0.5ex]{Variable}}
        & \multicolumn{5}{c}{Averages}\\
    \cmidrule{3-7}
    &               & \mcx{Factor 1} & \mcx{Factor 2} & \mcx{Factor 3} & \mcx{Factor 4} & \mcx{Factor 5}    \\
    \midrule
Section 1   & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
    \midrule
Section 2   &       &                &                &                &                &                   \\
Section 2.2 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 2.3 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 2.4 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
    \midrule
Section 3   &       &                &                &                &                &                   \\
Section 3.2 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 3.3 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 3.4 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
    \midrule
Section 4   &       &                &                &                &                &                   \\
Section 4.2 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 4.3 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 4.4 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
    \midrule
Section 5   &       &                &                &                &                &                   \\
Section 5.2 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 5.3 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
Section 5.4 & 11.11 & 22.22          & 33.33          & 44.44          & 55.55          & 66.66             \\
\bottomrule
\end{tabularx}
\end{table}
\lipsum[1-8]
\end{document}

enter image description here

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.