# Formatting with supertabular and figures

I am having difficulties formatting a supertabular table that spans multiple pages, is the width of the page, and has images and text combined inside cells. My first problem is that the table seem to be wider than the \textwidth that I am trying to set the width to. Secondly, when an image is inserted, the rest of the text is bumped down. Thirdly, when using the image and having enough rows to span more than one page, the first page turns out empty, the second page contains the first cells of the table, and the third page contains the third page of cells from the table. Here is my code followed by some images to show what I mean.

\documentclass{book}

\usepackage{graphicx}
\usepackage{placeins}
\usepackage[margin=1.0in]{geometry}
\usepackage{booktabs,supertabular}
\usepackage[table]{xcolor}
\usepackage{refcount}
\usepackage{makecell}

\pagestyle{plain}

\ifnum\value{#1}=\value{#2}
#3
\else
#3 (Sheet~\the\numexpr\value{page}+1-\the\numexpr\value{#1}~of~\the\numexpr\value{#2}+1-\the\numexpr\value{#1})
\fi
}

\newcommand{\TableCell}[1]{
\multicolumn{1}{p{0.25\linewidth}}{#1}
}

\begin{document}

\newcounter{StartTableCounter}
\newcounter{EndTableCounter}
\setcounter{StartTableCounter}{\getpagerefnumber{StartTable}}
\setcounter{EndTableCounter}{\getpagerefnumber{EndTable}}

}
}
\tabletail{\hline}
\tablelasttail{\hline}
\label{StartTable}
\begin{supertabular*}{\linewidth}{p{0.25\linewidth}|p{0.25\linewidth}|p{0.25\linewidth}|p{0.25\linewidth}}

\includegraphics[width=\linewidth]{blackbox.jpeg} &
Content 2 &
Content 3 &
Long text with lots of words thats more than one line but not one really big word which apparently can cause some problems.\\\hline

\end{supertabular*}
\label{EndTable}

\end{document}


which produces:

and when I add more rows:

As you can see, empty first page, wrong second page. To summarize, why does the table extend past the \textwidth? Why does the picture force the rest of the content down? And why does the page formatting get weird when I introduce pictures into the mix?

EDIT: Here is what the table looks like without a picture:

Aside from the overspill of the columns, I have found a solution to some of the other issue. Simply change the TableCell command to look like:

\newcommand{\TableCell}[1]{
\makecell*[{{p{\linewidth}}}]{#1}
}


Here would be the new code in full. This includes a couple minor changes like centering the table headers and putting the sheet counters in the first and last elements of the table to give more accurate sheet counts.

\documentclass{book}

\usepackage{graphicx}
\usepackage{placeins}
\usepackage{anyfontsize}
\usepackage{fontspec}
\usepackage[margin=1.0in]{geometry}
\usepackage{tocloft}
\usepackage{scrextend}
\usepackage{caption}
\usepackage{booktabs,supertabular}
\usepackage[table]{xcolor}
\usepackage{refcount}
\usepackage{makecell}
\usepackage{tcolorbox}
\usepackage{pifont}
\usepackage{hyperref}

\pagestyle{plain}

\definecolor{noteOutline}{rgb}{0.122, 0.435, 0.698}
\definecolor{noteBackground}{RGB}{161, 192, 255}

\setlength\extrarowheight{2pt}

\newcommand{\MyChapter}[2]{
\phantomsection
\begin{center}
{\textbf{\Huge{#1}}}\\[15pt]

{\textbf{\huge{#2}}}
\end{center}
}

\ifnum\value{#1}=\value{#2}
#3
\else
#3 (Sheet~\the\numexpr\value{page}+1-\the\numexpr\value{#1}~of~\the\numexpr\value{#2}+1-\the\numexpr\value{#1})
\fi
}

\newcommand{\TableCell}[1]{
\makecell*[{{p{\linewidth}}}]{#1}
}

\newcommand{\thickline}{
\Xhline{4\arrayrulewidth}
}

\begin{document}

\MyChapter{Section 1}{Title}

\begin{center}
\newcounter{Table10StartTableCounter}
\newcounter{Table10EndTableCounter}
\setcounter{Table10StartTableCounter}{\getpagerefnumber{Table10StartTable}}
\setcounter{Table10EndTableCounter}{\getpagerefnumber{Table10EndTable}}

\multicolumn{1}{>{\centering}p{0.333262\linewidth}|}{\cellcolor{gray!25}{Cell 1}} &
\multicolumn{1}{|>{\centering}p{0.333369\linewidth}}{\cellcolor{gray!25}{Cell 2}} &
\multicolumn{1}{|>{\centering}p{0.333369\linewidth}}{\cellcolor{gray!25}{Cell 4}}
\\\hline
}
\multicolumn{1}{>{\centering}p{0.333262\linewidth}|}{\cellcolor{gray!25}{Cell 1}} &
\multicolumn{1}{|>{\centering}p{0.333369\linewidth}}{\cellcolor{gray!25}{Cell 2}} &
\multicolumn{1}{|>{\centering}p{0.333369\linewidth}}{\cellcolor{gray!25}{Cell 4}}
\\\hline
}
\tabletail{\thickline}
\tablelasttail{\thickline}
\begin{supertabular*}{\linewidth}{p{0.333262\linewidth}|p{0.333369\linewidth}|p{0.333369\linewidth}}
\TableCell{Cell 4}\label{Table10StartTable} &
\TableCell{Cell 5} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 7} &
\TableCell{Cell 8} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 1} &
\TableCell{Cell 2} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 4} &
\TableCell{Cell 5} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 7} &
\TableCell{Cell 8} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 1} &
\TableCell{Cell 2} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 4} &
\TableCell{Cell 5} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 7} &
\TableCell{Cell 8} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 1} &
\TableCell{Cell 2} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 4} &
\TableCell{Cell 5} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\\\hline
\TableCell{Cell 7} &
\TableCell{Cell 8} &
\TableCell{\includegraphics[width=0.333369\linewidth]{image1.jpg}}\label{Table10EndTable}\\
\end{supertabular*}
\end{center}

\end{document}