3

I am using a template I found and it usually gives me no problems, but I am having an issue with table placement. I am trying to print four tables on the last page of my document, but the fourth one keeps moving to another page even though there is plenty of room for it on the page prior. How can I fix this?

(A few comments- apologies in advance for the formatting- couldn't figure out how to block paste text so the indentations are messed up. Also, I know there are a lot of extras that I don't need for what is included here, but there is nothing I would like to remove from the code at this time.)

Thanks in advance!

\documentclass[11pt, a4paper]{article}
\usepackage[inner=2cm,outer=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\pagestyle{empty}
\usepackage{graphicx}
\usepackage{fancyhdr, lastpage, bbding, pmboxdraw}
\usepackage[usenames,dvipsnames]{color}
\definecolor{darkblue}{rgb}{0,0,.6}
\definecolor{darkred}{rgb}{.7,0,0}
\definecolor{darkgreen}{rgb}{0,.6,0}
\definecolor{red}{rgb}{.98,0,0}
\usepackage[colorlinks,pagebackref,pdfusetitle,urlcolor=darkblue,citecolor=darkblue,linkcolor=darkred,bookmarksnumbered,plainpages=false]{hyperref}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\pagestyle{fancyplain}
\fancyhf{}
\lhead{ \fancyplain{}{MAT 135} }
\rhead{ \fancyplain{}{March 5, 2019} }
\thispagestyle{plain}
\usepackage{listings}
\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}
\usepackage{verbatim}
\usepackage{fancyvrb}
\usepackage{acronym}
\usepackage{hyperref}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{array}
\usepackage{multicol}
\VerbatimFootnotes
\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}
\definecolor{lightlightgray}{gray}{0.93}
\lstset{
basicstyle=\ttfamily,
keywordstyle=\color{OliveGreen},
commentstyle=\color{gray},
numbers=left,
numberstyle=\tiny,
stepnumber=1,
numbersep=5pt,
backgroundcolor=\color{lightlightgray},
frame=none,
tabsize=2,
captionpos=t,
breaklines=true,
breakatwhitespace=false,
showspaces=false,
showtabs=false,
columns=flexible,
morekeywords={__global__, __device__},
}
\begin{document}
\begin{center}
{\Large{Sections 4.2 and 4.3 Questions}}
\end{center}
\begin{center}
March 5, 2019
\end{center}
\vspace{5mm}
\noindent 1. Consider the functions $f(x)=x^2$ and $g(x)=\sqrt{x}$ on the interval $(0,\infty)$. Compare their slopes.
\vspace{5mm}
\noindent 2. Define concave upward and concave downward.
\vspace{5mm}
\newpage
\begin{table}[h]
  \begin{center
\begin{tabular}{|c|c|c|c|}
  \hline
  \textbf{f''(x)} & - & 0 & +\\
  \hline
  \textbf{f'(x)} & decreasing & horizontal tangent & increasing\\
  \hline
  \textbf{f(x)} & concave down & inflection point & concave up\\
  \hline
\end{tabular}
  \end{center}
\end{table}
\begin{table}[h]
  \begin{center}
\begin{tabular}{|c|c|c|c|}
  \hline
  \textbf{f'(x)} & - & 0 & +\\
  \hline
  \textbf{f(x)} & decreasing & horizontal tangent & increasing\\
  \hline
\end{tabular}
  \end{center}
\end{table}
\begin{table}[h]
  \begin{center}
  \caption{Identifying Inflection Points of $f$ Based on The Sign of $f''$}
\begin{tabular}{|c|c|c|c|}
  \hline
  & c & & \\
  \hline
  - & & + & inflection point\\
  \hline
  - & & - & not an inflection point\\
  \hline
  + & & - & inflection point\\
  \hline
  + & & + & not an inflection point\\
  \hline
\end{tabular}
  \end{center}
\end{table}
\begin{table}[h]
  \begin{center}
  \caption{Classifying Local Extrema of $f$ Based on the Sign of $f'$
\begin{tabular}{|c|c|c|c|}
  \hline
  & c & & \\
  \hline
  - & & + & local minimum\\
  \hline
  - & & - & not local extremum\\
  \hline
  + & & - & local maximum\\
  \hline
  + & & + & not local extremum\\
  \hline
\end{tabular}
  \end{center}
\end{table}
\end{document}
4

The immediate cause of the issue you describe is that you have four table environments, while the article document class by default only allows up to three such environments to be placed on a single page. That's why the fourth table gets pushed to the next page.

One way to solve this issue is to issue the instructions

\setcounter{totalnumber}{4}
\setcounter{topnumber}{4}
\setcounter{bottomnumber}{4}

in the preamble. Of course, if you find yourself needing to place 7 (presumably very small, right?) table environments on a single page, you should change the above to

\setcounter{totalnumber}{7}
\setcounter{topnumber}{7}
\setcounter{bottomnumber}{7}

Incidentally, I can't help but remark that the overall quality of your LaTeX is far from perfect. For sure, the code contains two syntax errors -- \begin{center and \caption{Classifying Local Extrema of $f$ Based on the Sign of $f'$; can you spot the missing curly braces? -- which must be fixed before the document can be compiled. And writing \textbf{f''(x)}, \textbf{f''(x)}, and\textbf{f''(x)} is bound to raise more than a few eyebrows, and it might even cause some readers' eyes to bleed profusely. Do please consider writing $\mathbf{f}''(\mathbf{x})}$, $\mathbf{f}'(\mathbf{x})}$, and $\mathbf{f}(\mathbf{x})}$ instead.

  • Thanks- I did not know this about the article document class! These errors your noticed only occurred when I inputted my code here- they are not present in my document. – MathStudent1324 Mar 4 at 18:42
  • @MathStudent1324 - Setting the totalnumber counter to 3 is not limited to the article document class. Many other document classes also feature this setting. – Mico Mar 4 at 18:44
  • Also, use \centering inside the table environment. The center environment adds unwanted vertical spacing. – Bernard Mar 4 at 18:50

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.