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}
\newcommand{\TableHeaderContent}[3]{
\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}}
\tablehead{
\multicolumn{4}{l}{\textbf{\TableHeaderContent{StartTableCounter}{EndTableCounter}{Table 1.1}}}\\\hline
\multicolumn{1}{p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 1}} &
\multicolumn{1}{|p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 2}} &
\multicolumn{1}{|p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 3}} &
\multicolumn{1}{|p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 4}}\\\hline
}
\tablefirsthead{
\multicolumn{4}{l}{\textbf{\TableHeaderContent{StartTableCounter}{EndTableCounter}{Table 1.1}}}\\\hline
\multicolumn{1}{p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 1}} &
\multicolumn{1}{|p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 2}} &
\multicolumn{1}{|p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 3}} &
\multicolumn{1}{|p{0.25\linewidth}}{\cellcolor{gray!25}\textbf{Header 4}}\\\hline
}
\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}
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?