1

Problem

Unable to get table and text boxes to share the same page.

The document spans two pages instead of one

Minimum Working Example

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage[paperheight=11in, paperwidth=17in, margin = 0.25cm]{geometry}
\usepackage{float}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage[absolute,overlay]{textpos}

\definecolor{patriarch}{rgb}{0.5, 0.0, 0.5}

\def\isize{0.80in}
\def\cpath{../graphics/zeros/checkers/}

\begin{document}
%
\def\arraystretch{7.3}
\begin{table}[ht]
    \begin{center}
        \begin{tabular}{ccccc ccccc ccccc ccc}
                %
            &&&&&&&& 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            &&&&&&& 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            &&&&&& 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            &&&&& 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            &&&& 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            &&& 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            & 
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} &&
            \includegraphics[ width = \isize ]{\cpath "n08-m02-re"} \\
                %
        \end{tabular}
    \end{center}
\end{table}
%
\begin{textblock*}{5in}(0.0in, 0.35in) % {block width} (x, y coords) 
    \begin{center}
        \huge{\color{patriarch}{\bf{My Table}}}
    \end{center}
\end{textblock*}
%
\begin{textblock*}{5in}(11.7in, 0.5in) 
    \Large{$a+b=c$}
\end{textblock*}
%
\end{document}

Questions consulted

Force table* to stay in the current page

Get a table and figure on the same page with captions & labels

Force figure placement in text

How to force a figure and a table to stay on the same page in LaTeX?

3
  • 1
    Do you get any warnings if you compile your code? Especially a warning such as "Float too large for page by ...pt"?
    – leandriis
    Mar 28 at 19:21
  • 1
    Are you sure that you need to place the tabular in a table environment? Mar 28 at 19:52
  • 1
    note size commands do not take an argument \Large{$a+b=c$} shoule be \Large $a+b=c$ (same for \Huge) Mar 28 at 20:43
2

x

The solution is to use the xcoffins package instead of textpos.

In short, it puts the material (text, tables, figures, tikzfigures, etc.) in special boxes. (called coffins, bad choice of a name)

It has several advantages:

(1) It allows the joining of these boxes in various ways with offsets. I used a box of zero size as frame \Framex to attach (\Join...) the other two with proper horizontal and vertical offsets

(2) The boxes are not floats and are typeset at the current insertion points. In this way you can place the boxes anywhere on the physical page, including hard-to-reach places such as corners.

In this particular case there are four steps:

(1) Assign with \NewCoffin.

(2) Fill with \SetHorizontalCoffin.

(3) Join the boxes to the \Framex with offsets X, Y.

(4) Typeset the frame with \TypesetCoffin after the tabular. Since it is a zero-size box, it stays on the same page. In this case, the offset is measured from (close to) the bottom right of the page, so X is negative (to move left) and Y is positive (to move up)

\documentclass{article}
\usepackage{amsmath, amssymb}
\usepackage[paperheight=11in, paperwidth=17in, margin = 0.25cm]{geometry}
\usepackage{float}
\usepackage{graphicx}
\usepackage[dvipsnames]{xcolor}
\usepackage[absolute,overlay]{textpos}

\definecolor{patriarch}{rgb}{0.5, 0.0, 0.5}

\def\isize{0.80in}
\def\cpath{../graphics/zeros/checkers/}

\usepackage{xcoffins}
\NewCoffin\MT
\NewCoffin\EQ
\NewCoffin\Framex

\begin{document}
    \SetHorizontalCoffin\MT{\color{patriarch}\bfseries \huge My Table}
    \SetHorizontalCoffin\EQ{\Large $a+b=c$}
    
    \JoinCoffins*\Framex[l,t]\MT[l,t](-1150pt,350pt) % (xoffset, yoffset)
    \JoinCoffins*\Framex[l,t]\EQ[l,t](-150pt,350pt)
    %
    \def\arraystretch{7.3}
    \begin{table}[ht]
            \centering
            \begin{tabular}{ccccc ccccc ccccc ccc}
                %
                &&&&&&&& 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                &&&&&&& 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                &&&&&& 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                &&&&& 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                &&&& 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                &&& 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                & 
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} &&
                \includegraphics[ width = \isize ]{example-grid-100x100pt} \\
                %
            \end{tabular}
    \TypesetCoffin\Framex
    \end{table}

    %   \begin{textblock*}{5in}(0.0in, 0.35in) % {block width} (x, y coords) 
    %       \begin{center}
    %           \huge{\color{patriarch}{\bf{My Table}}}
    %       \end{center}
    %   \end{textblock*}
    %   %
    %   \begin{textblock*}{5in}(11.7in, 0.5in) 
    %       \Large{$a+b=c$}
    %   \end{textblock*}
    %   %
\end{document}

Other examples in

I need a rather complex layout for a scholarly edition and don't know where to start

How do I binpack a set of tables on a page?

How to create a word/equation/diagram collage

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.