4

I want to put two tables on one page but when it won't be positioned at the top of the page. this is the code:

\documentclass[
a4paper,
12pt,
blue,
rgb,
]{tubsbook}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{array,multirow}
\newcommand\mcbf[1]{\multicolumn{2}{|c|}{\textbf{#1}}}
\newcommand\mlbf[1]{\multicolumn{2}{|l|}{\textbf{#1}}}
\usepackage{graphicx}
\usepackage[activate]{pdfcprot}

\begin{document}
\begin{table}[htb]
\centering
\renewcommand\arraystretch{1.2}
\begin{tabular}{|>{\bfseries}c|>{\bfseries}l|c|}
\hline
\mcbf{Cortex A9 Parameters}                         & \textbf{Values}   \\ \hline
\mcbf{Core clock}                                   & 800 MHz           \\ \hline
\multirow{5}{*}{L2}             &  Size             & 512 kB            \\ \cline{2-3}
                            &  Associativity    & 8                 \\ \cline{2-3}
                            &  Latency          & 8                 \\ \cline{2-3}
                            &  MSHRs            & 11                \\ \cline{2-3}
                            &  Write buffers    & 9                 \\ \hline
\multirow{4}{*}{L1 - I}        &  Size             & 32 kB             \\ \cline{2-3}
                            &  Associativity    & 4                 \\ \cline{2-3}
                            &  Latency          & 1                 \\ \cline{2-3}
                            &  MSHRs            & 2                 \\ \hline
\multirow{5}{*}{L1 - D}        &  Size             & 32 kB             \\ \cline{2-3}
                            &  Associativity    & 4                 \\ \cline{2-3}
                            &  Latency          & 1                 \\ \cline{2-3}
                            &  MSHRs            & 4                 \\ \cline{2-3}
                            &  Write buffers    & 16                \\ \hline
{Stride prefetcher}            &  Degree           & 1                 \\ \hline
\multirow{2}{*}{Global BP}     &  Entries          & 4096              \\ \cline{2-3}
                            &  Bits             & 2                 \\ \hline
\mlbf{BTB entries}                                  & 4096              \\ \hline
\mlbf{Return Address Stack (RAS) entries}           & 8                 \\ \hline
\mlbf{Issues width}                                 & 2                 \\ \hline
\mlbf{Pipeline stages}                              & 8                 \\ \hline
\mlbf{Physical INT registers}                       & 62                \\ \hline
\mlbf{Physical FP registers}                        & 256               \\  \hline
\mlbf{IQ entries}                                   & 32                \\ \hline
\mlbf{LSQ entries}                                  & 8 / 8             \\ \hline
\mlbf{ROB entries}                                  & 40                \\ \hline
\end{tabular}%
\caption{My caption}
\label{my-label}
\end{table}
\end{document}

And this is how the table is positioned: enter image description here

A.nechi
  • 345
  • 2
    your question asks why two tables are not placed on a page but your example only has one table. What answer do you want? You will get one or two tables on the page depending if the unshown second table is small enough to fit – David Carlisle Aug 20 '16 at 22:32
  • 1
    tables on float pages are vertically positioned by default but obviously this one would move up if there was a second table – David Carlisle Aug 20 '16 at 22:33
  • Actually, I want to place this table in the top of the page to place another one beneath it – A.nechi Aug 20 '16 at 22:33
  • 2
    add a second table, and some text and that will most likely happen – David Carlisle Aug 20 '16 at 22:33
  • Yes, you are So right. Thank you, I thought its position is fixed... Sorry, I'm a newbie. – A.nechi Aug 20 '16 at 22:37
  • 1
    See, if the table option change from [htb] to [!ht] will help. – Zarko Aug 20 '16 at 22:38
  • 1
    @Zarko best not to recommend ! initially it's a sledgehammer of last resort for special cases where you want to over-ride the documentclass – David Carlisle Aug 20 '16 at 22:40
  • actually I hadn't noticed you had used [htb] that prevents float pages normally unless (as here) the table reaches the end of the document and is flushed out by \clearpage better not to use this option, or if you do use it, include p. The default is [tbp] – David Carlisle Aug 20 '16 at 22:42
  • @DavidCarlisle, yes, use of [!ht] is a sledgehammer of last resort ... but, testing your suggestion to use [tbp] and adding after table\lipsum[2]put\lipsum[2]text on the first page and move table on the second one (verticaly centered). This gave me to thing that the table is so big that it require whole page for itself. In test I use standardarticle` document class. – Zarko Aug 20 '16 at 22:51
  • @Zarko yes I expect it is, but still, either having just a few lines under the table is acceptable in which case \textfraction should be changed or it isn't in which case you shouldn't use ! to force it to happen:-) – David Carlisle Aug 20 '16 at 23:03
  • @Zarko : It's a university template i can't change it – A.nechi Aug 20 '16 at 23:07
  • 1
    @A.nechi, your university template hasn't anything with your problem. I reproduce it with article document. It seems that your table is taller than fraction of text height reserved for floats in page. So a possible solution is change default settings, as noted David in his comments. About his see http://tex.stackexchange.com/questions/192622/is-there-a-value-for-textfraction-and-totalnumber-floatpagefraction-that-i-s and also http://tex.stackexchange.com/questions/68516/avoid-that-figure-gets-its-own-page. As sledgehammer of last resort can serve my suggestion in my comment above. – Zarko Aug 20 '16 at 23:38
  • 1
    Most book classes have asymmetrical margins; the larger one at the outside margin of the page. They may also leave space for marginal notes. So left-right centering is within the margins rather than the page. Hope that is what you mean. – Herb Schulz Aug 21 '16 at 16:09

1 Answers1

2

See: two tables on one page.

\documentclass[
a4paper,
12pt,
blue,
rgb,
]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{lipsum}
\usepackage{listings}
\usepackage{hyperref}
\usepackage{array,multirow}
\newcommand\mcbf[1]{\multicolumn{2}{|c|}{\textbf{#1}}}
\newcommand\mlbf[1]{\multicolumn{2}{|l|}{\textbf{#1}}}
\usepackage{graphicx}
\usepackage[activate]{pdfcprot}
\usepackage[margin=1in]{geometry}

\begin{document}
\begin{table}[p]
\centering
\renewcommand\arraystretch{1.2}
\begin{tabular}{|>{\bfseries}c|>{\bfseries}l|c|}
\hline
\mcbf{Cortex A9 Parameters}                         & \textbf{Values}   \\ \hline
\mcbf{Core clock}                                   & 800 MHz           \\ \hline
\multirow{5}{*}{L2}             &  Size             & 512 kB            \\ \cline{2-3}
                            &  Associativity    & 8                 \\ \cline{2-3}
                            &  Latency          & 8                 \\ \cline{2-3}
                            &  MSHRs            & 11                \\ \cline{2-3}
                            &  Write buffers    & 9                 \\ \hline
\multirow{4}{*}{L1 - I}        &  Size             & 32 kB             \\ \cline{2-3}
                            &  Associativity    & 4                 \\ \cline{2-3}
                            &  Latency          & 1                 \\ \cline{2-3}
                            &  MSHRs            & 2                 \\ \hline
\multirow{5}{*}{L1 - D}        &  Size             & 32 kB             \\ \cline{2-3}
                            &  Associativity    & 4                 \\ \cline{2-3}
                            &  Latency          & 1                 \\ \cline{2-3}
                            &  MSHRs            & 4                 \\ \cline{2-3}
                            &  Write buffers    & 16                \\ \hline
{Stride prefetcher}            &  Degree           & 1                 \\ \hline
\multirow{2}{*}{Global BP}     &  Entries          & 4096              \\ \cline{2-3}
                            &  Bits             & 2                 \\ \hline
\mlbf{BTB entries}                                  & 4096              \\ \hline
\mlbf{Return Address Stack (RAS) entries}           & 8                 \\ \hline
\mlbf{Issues width}                                 & 2                 \\ \hline
\mlbf{Pipeline stages}                              & 8                 \\ \hline
\mlbf{Physical INT registers}                       & 62                \\ \hline
\mlbf{Physical FP registers}                        & 256               \\  \hline
\mlbf{IQ entries}                                   & 32                \\ \hline
\mlbf{LSQ entries}                                  & 8 / 8             \\ \hline
\mlbf{ROB entries}                                  & 40                \\ \hline
\end{tabular}%
\caption{My caption}
\label{my-label}
\end{table}
\begin{table}[p]
    \centering
    \renewcommand\arraystretch{1.2}
    \begin{tabular}{|>{\bfseries}c|>{\bfseries}l|c|}
        \hline
        \mcbf{Cortex A9 Parameters}                         & \textbf{Values}   \\ \hline
        \mcbf{Core clock}                                   & 800 MHz           \\ \hline
        \multirow{5}{*}{L2}             &  Size             & 512 kB            \\ \cline{2-3}
        &  Associativity    & 8                 \\ \cline{2-3}
        &  Latency          & 8                 \\ \hline
    \end{tabular}%
    \caption{My caption}
    \label{my-label2}
\end{table}
\end{document}

enter image description here

JPi
  • 13,595