1

I have a table which has many columns. They can't fit in one page on PDF file. I would like to find some packages to print this table in several pages automatically. Each page should have same table column headers and table headers. Columns continue to overflow to the next several pages dynamically (Maybe several pages). It depends on the date range specified.

My question is different from the one mentioned in the duplicate comments: Table and multi-page which only prints 2 pages in a book.

Here is my MWV:

%!TEX TS-Program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass{article}
\usepackage{graphics}
\usepackage{fancyhdr}
\usepackage{ctable}
\usepackage{tabularx}
\usepackage[margin=2.5cm]{geometry}

\setlength\parindent{0pt}

\newcommand{\sectionheader}[1] {
\textbf{#1}

\rule{\textwidth}{6pt}
}

\setlength{\heavyrulewidth}{0.12em}

\pagenumbering{arabic}
\pagestyle{fancy}
\lhead{Patient Name: Claire  Roberts}
\rhead{\thepage}
\cfoot{}

\begin{document}
\thispagestyle{empty}
\textbf{Patient Information for Claire  Roberts}

Last updated on February 19, 2016

\sectionheader{SYMPTOMS}
\begin{tabularx}{\textwidth}{l*{16}X}
    \textbf{PERCEPTION}
     & {6/2/16} & {6/3/16} & {6/4/16} & {6/5/16} & {6/6/16} & {6/7/16} & {6/8/16} & {6/9/16} & {6/10/16} & {6/11/16} & {6/12/16} & {6/13/16} & {6/14/16} & {6/15/16} & {6/16/16} & {6/17/16}\\
{SATISFACTION}
            & -
            & -
            & -
            & 2
            & -
            & 2
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\
\hline
    \textbf{VOID}
     & {6/2/16} & {6/3/16} & {6/4/16} & {6/5/16} & {6/6/16} & {6/7/16} & {6/8/16} & {6/9/16} & {6/10/16} & {6/11/16} & {6/12/16} & {6/13/16} & {6/14/16} & {6/15/16} & {6/16/16} & {6/17/16}\\
{AWAKE}
            & -
            & 5
            & -
            & -
            & 2
            & 1
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\{SLEEPING}
            & 5
            & -
            & -
            & 1
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\{URGENCY}
            & -
            & -
            & 2
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\
\hline
    \textbf{UR}
     & {6/2/16} & {6/3/16} & {6/4/16} & {6/5/16} & {6/6/16} & {6/7/16} & {6/8/16} & {6/9/16} & {6/10/16} & {6/11/16} & {6/12/16} & {6/13/16} & {6/14/16} & {6/15/16} & {6/16/16} & {6/17/16}\\
{UR\_LEAK\_AMOUNT}
            & -
            & -
            & -
            & -
            & Moderate
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\{TOTAL}
            & -
            & -
            & -
            & 1
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\
\hline
    \textbf{BM}
     & {6/2/16} & {6/3/16} & {6/4/16} & {6/5/16} & {6/6/16} & {6/7/16} & {6/8/16} & {6/9/16} & {6/10/16} & {6/11/16} & {6/12/16} & {6/13/16} & {6/14/16} & {6/15/16} & {6/16/16} & {6/17/16}\\
{AWAKE}
            & -
            & -
            & -
            & -
            & -
            & 3
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\{SLEEPING}
            & -
            & -
            & -
            & -
            & 5
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\{SOIL\_AMOUNT}
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\
\hline
    \textbf{BOWEL}
     & {6/2/16} & {6/3/16} & {6/4/16} & {6/5/16} & {6/6/16} & {6/7/16} & {6/8/16} & {6/9/16} & {6/10/16} & {6/11/16} & {6/12/16} & {6/13/16} & {6/14/16} & {6/15/16} & {6/16/16} & {6/17/16}\\
{AMOUNT}
            & -
            & -
            & 6
            & -
            & 5
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\{TOTAL}
            & -
            & -
            & -
            & 8
            & -
            & 9
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\
\hline
    \textbf{PADS}
     & {6/2/16} & {6/3/16} & {6/4/16} & {6/5/16} & {6/6/16} & {6/7/16} & {6/8/16} & {6/9/16} & {6/10/16} & {6/11/16} & {6/12/16} & {6/13/16} & {6/14/16} & {6/15/16} & {6/16/16} & {6/17/16}\\
{TOTAL}
            & -
            & -
            & -
            & 9
            & -
            & 8
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
    \\
\hline
\end{tabularx}
\newpage

\bigskip
\newpage

\end{document}

Here is what I have now, extra columns don't print to the next page and just print on the top of other date column: enter image description here

  • Would it be better to switch the columns/rows, so that you get a long table, instead of a wide one? – Runar Jun 17 '16 at 21:14
  • @runartrollet, probably we want to do a wide table in this case. – y.h Jun 20 '16 at 18:52
  • Just out of curiosity, why is it you want to print this on several pages, when it could, with some changes, be typeset onto one? – Runar Jun 20 '16 at 18:55
  • The date range could be a couple of days, one month or even two month. The PDF file could print one page table or several pages table depends on the date range specified. We allow users to define date range on the fly. – y.h Jun 20 '16 at 20:10
1

I suggest you place all dates -- rotated 90 degrees -- in a new, separate header row. With this change, it's not too difficult to typeset the full table on a single page.

enter image description here

%!TEX TS-Program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass{article}
\usepackage{graphicx,booktabs,fancyhdr}
\usepackage[margin=2.5cm]{geometry}

\setlength\parindent{0pt}

\newcommand{\sectionheader}[1] {\textbf{#1}\par
\rule{\textwidth}{4pt}}

\setlength{\heavyrulewidth}{0.12em}

\pagenumbering{arabic}
\pagestyle{fancy}
\lhead{Patient Name: Claire  Roberts}
\rhead{\thepage}
\cfoot{}

\begin{document}
\thispagestyle{empty}

\textbf{Patient Information for Claire  Roberts}

Last updated on June 19, 2016

\sectionheader{SYMPTOMS}

\begin{tabular}{@{}l*{16}{c}@{}}
\addlinespace
& \rotatebox{90}{6/2/16}  & \rotatebox{90}{6/3/16} 
& \rotatebox{90}{6/4/16}  & \rotatebox{90}{6/5/16} 
& \rotatebox{90}{6/6/16}  & \rotatebox{90}{6/7/16} 
& \rotatebox{90}{6/8/16}  & \rotatebox{90}{6/9/16} 
& \rotatebox{90}{6/10/16} & \rotatebox{90}{6/11/16} 
& \rotatebox{90}{6/12/16} & \rotatebox{90}{6/13/16} 
& \rotatebox{90}{6/14/16} & \rotatebox{90}{6/15/16} 
& \rotatebox{90}{6/16/16} & \rotatebox{90}{6/17/16}\\
\addlinespace
\textbf{PERCEPTION}\\
SATISFACTION
            & -
            & -
            & -
            & 2
            & -
            & 2
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & - \\
\addlinespace
\textbf{VOID}\\
AWAKE
            & -
            & 5
            & -
            & -
            & 2
            & 1
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
SLEEPING
            & 5
            & -
            & -
            & 1
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
URGENCY
            & -
            & -
            & 2
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
\addlinespace
\textbf{UR}\\
UR\_LEAK\_AMOUNT
            & -
            & -
            & -
            & -
            & Mod.
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
TOTAL
            & -
            & -
            & -
            & 1
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
\addlinespace
\textbf{BM}\\
AWAKE
            & -
            & -
            & -
            & -
            & -
            & 3
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
SLEEPING
            & -
            & -
            & -
            & -
            & 5
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
SOIL\_AMOUNT
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
\addlinespace
\textbf{BOWEL}\\
AMOUNT
            & -
            & -
            & 6
            & -
            & 5
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
TOTAL
            & -
            & -
            & -
            & 8
            & -
            & 9
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
\addlinespace
\textbf{PADS}\\
TOTAL
            & -
            & -
            & -
            & 9
            & -
            & 8
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -
            & -\\
\bottomrule
\end{tabular}

\end{document}
  • Thanks for the solution. But the requirement is to print several pages. The date range could be lst one or two month. – y.h Jun 20 '16 at 18:50
0

Finally, I came up with the solution, but I have to do it manually by separating the date range in different segment and then print each segment on different page.

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.