1

I have a very long and narrow table in MS Word that looks like this and I would like to re-write it in LaTeX. At the end of each column, the table should continue to the right, and after six columns it should continue on the next page.

Even though it does not in the example below, the header "Tix Lap n" should appear at the top of each column.

Six-column table

In Word, this table is extremely unstable.

Here's the code I've got so far (modified from the answer to this question: Supertabular + minipage), which makes a two-column version of the six-column table I want. I'm struggling to make it into six columns. How could I do this?

\documentclass[12pt]{article}
\usepackage{supertabular}
\usepackage[a4paper,top=0.3in, bottom = 0.6in, left = 0.3in, right = 0.3in,heightrounded]{geometry}
\usepackage{microtype,textcomp}
\usepackage{array}
\usepackage{multicol}
\usepackage{makecell}
\newcommand\myrows{%
 NA & NA & NA \\
 NA & NA & NA \\
  NA & NA & NA \\
 NA & NA & NA \\
  NA & NA & NA \\\hline
  \multicolumn{3}{|c|}{Layer XYZ}\\ \hline
 NA & NA & NA \\
  NA & NA & NA \\
 NA & NA & NA \\
  NA & NA & NA \\
 NA & NA & NA}
\newcommand\Myrow{%
    \myrows\\
    \myrows\\
    \myrows\\
    \myrows\\
    \myrows\\
    \myrows\\
    \myrows
    }
\newcounter{rowno}
\setcounter{rowno}{0}
%==================================================================
\begin{document}
%===============================================================
%This is some dummy text just for demo used here. It is in one column mode.
\twocolumn
\bgroup
\centering
\tablefirsthead{\hline Tix& Lap& n\\\hline}
%
\tablehead{
%\multicolumn{3}{c}%
%{{\bfseries  Continued from previous page}} \\
\hline
Tix& Lap & n\\ \hline}
%
\tabletail{
%\hline \multicolumn{3}{|r|}{{Continued}} \\
 \hline}
%
\tablelasttail{
%\multicolumn{3}{|r|}{{Concluded}}
 \hline}
%
\begin{supertabular}{|ccc|}

    \multicolumn{3}{|c|}{Layer G100}\\ \hline
    113 & X3 & 1\\
    178 & \thead[l]{W4\\+Z1}&1\\
    211 & Y3 &12\\
    \Myrow\\
    \Myrow\\
\end{supertabular}%
\par
\egroup
\onecolumn
\end{document}

Which renders as:

enter image description here

Version info, could indeed benefit from a little updating:

*File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size12.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
supertabular.sty    2004/02/20 v4.1e the supertabular environment
geometry.sty    2010/09/12 v5.6 Page Geometry
  keyval.sty    2014/05/08 v1.15 key=value parser (DPC)
   ifpdf.sty    2011/01/30 v2.3 Provides the ifpdf switch (HO)
  ifvtex.sty    2010/03/01 v1.5 Detect VTeX and its facilities (HO)
 ifxetex.sty    2010/09/12 v0.6 Provides ifxetex conditional
microtype.sty    2013/05/23 v2.5a Micro-typographical refinements (RS)
microtype-pdftex.def    2013/05/23 v2.5a Definitions specific to pdftex (RS)
microtype.cfg    2013/05/23 v2.5a microtype main configuration file (RS)
textcomp.sty    2005/09/27 v1.99g Standard LaTeX package
  ts1enc.def    2001/06/05 v3.0e (jk/car/fm) Standard LaTeX file
   array.sty    2008/09/09 v2.4c Tabular extension package (FMi)
multicol.sty    2014/04/23 v1.8e multicolumn formatting (FMi)
multirow.sty    
makecell.sty    2009/08/03 V0.1e Managing of Tab Column Heads and Cells
  ts1cmr.fd    1999/05/25 v2.5h Standard LaTeX font definitions
  mt-cmr.cfg    2013/05/19 v2.2 microtype config. file: Computer Modern Roman (
RS)
 ***********

1 Answer 1

1

Update:

Using \multirow from multirow package to replace \thead, the first column is balanced now.

% in preamble
\usepackage{multirow}

% inside "supertabular" environment
        113          & X3  &         1          \\
\multirow{2}{*}{178} & W4  & \multirow{2}{*}{1} \\
                     & +Z1 &                    \\

enter image description here

Full example:

\documentclass[12pt]{article}
\usepackage{supertabular}
\usepackage[a4paper,top=0.3in, bottom = 0.6in, left = 0.3in, right = 0.3in, heightrounded]{geometry}
\usepackage{microtype,textcomp}
\usepackage{array}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{makecell}


\newcommand\myrows{%
  NA & NA & NA \\ 
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\ \hline
  \multicolumn{3}{|c|}{Layer XYZ}\\ \hline
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA}
\newcommand\Myrow{%
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows
}

\begin{document}
\begin{multicols*}{6}
  \let\mcnewpage=\newpage
  \makeatletter
  \renewcommand\newpage{%
    \if@firstcolumn
      \hrule width\linewidth height0pt
      \columnbreak
  \else
    \mcnewpage
  \fi
  }
  \makeatother

  \tablefirsthead{\hline Tix & Lap & n\\ \hline}
  \tablehead     {\hline Tix & Lap & n\\ \hline}
  \tabletail     {\hline}
  \tablelasttail {\hline}

  \begin{supertabular}{|ccc|}
    \multicolumn{3}{|c|}{Layer G100}\\ \hline
    113 &  X3 & 1  \\
    113 &  X3 & 1  \\
    \multirow{2}{*}{178} & W4  & \multirow{2}{*}{1} \\
        & +Z1 &    \\
    211 & Y3  & 12 \\
    \Myrow \\
    \Myrow \\
    \Myrow \\
    \Myrow \\
  \end{supertabular}
\end{multicols*}

\end{document}

My local version info (texlive 2020 with latest pacakges)

 *File List*
 article.cls    2019/12/20 v1.4l Standard LaTeX document class
  size12.clo    2019/12/20 v1.4l Standard LaTeX file (size option)
supertabular.sty    2020/02/02 v4.1g the supertabular environment
geometry.sty    2020/01/02 v5.9 Page Geometry
  keyval.sty    2014/10/28 v1.15 key=value parser (DPC)
  ifvtex.sty    2019/10/25 v1.7 ifvtex legacy package. Use iftex instead.
   iftex.sty    2020/03/06 v1.0d TeX engine tests
   array.sty    2019/08/31 v2.4l Tabular extension package (FMi)
multicol.sty    2019/12/09 v1.8y multicolumn formatting (FMi)
multirow.sty    2019/05/31 v2.5 Span multiple rows of a table
makecell.sty    2009/08/03 V0.1e Managing of Tab Column Heads and Cells
l3backend-pdfmode.def    2020-05-05 L3 backend support: PDF mode
 ***********

Original answer:

The following example is based on this answer to multicolumn long table or enumeration, note the first column is not balanced.

\documentclass[12pt]{article}
\usepackage{supertabular}
\usepackage[a4paper,top=0.3in, bottom = 0.6in, left = 0.3in, right = 0.3in, heightrounded]{geometry}
\usepackage{microtype,textcomp}
\usepackage{array}
\usepackage{multicol}
\usepackage{makecell}

\newcommand\myrows{%
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\\hline
  \multicolumn{3}{|c|}{Layer XYZ}\\ \hline
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA \\
  NA & NA & NA}
\newcommand\Myrow{%
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows\\
  \myrows
}
\newcounter{rowno}
\setcounter{rowno}{0}
%==================================================================
\begin{document}
%===============================================================
%This is some dummy text just for demo used here. It is in one column mode.


\begin{multicols*}{6}
  \let\mcnewpage=\newpage
  \makeatletter
  \renewcommand\newpage{%
          \if@firstcolumn
                  \hrule width\linewidth height0pt
                  \columnbreak
          \else
                  \mcnewpage
          \fi
  }
  \makeatother
  \tablefirsthead{\hline Tix& Lap& n\\\hline}
  %
  \tablehead{
  %\multicolumn{3}{c}%
  %{{\bfseries  Continued from previous page}} \\
  \hline
  Tix& Lap & n\\ \hline}
  %
  \tabletail{
  %\hline \multicolumn{3}{|r|}{{Continued}} \\
   \hline}
  %
  \tablelasttail{
  %\multicolumn{3}{|r|}{{Concluded}}
   \hline}
  \begin{supertabular}{|ccc|}
      \multicolumn{3}{|c|}{Layer G100}\\ \hline
      113 & X3 & 1\\
      178 & \thead[l]{W4\\+Z1}&1\\
      211 & Y3 &12\\
      \Myrow\\
      \Myrow\\
      \Myrow\\
      \Myrow\\
  \end{supertabular}
\end{multicols*}

\end{document}

enter image description here

8
  • Thanks for this. The first column appears to be not balanced because of the \thead{}. Any way around this?
    – Pertinax
    Commented May 12, 2020 at 20:05
  • @Pertinax Answer updated, now it's balanced. Commented May 12, 2020 at 20:31
  • Hmm, running the code of your new answer, the first column appears to be one row shorter than all the other ones. This even persists if I take out the whole line with a "+". And this problem goes away if I remove this line: \tablehead {\hline Tix & Lap & n\\ \hline}, but then I don't have column headers after the first column. Any tips?
    – Pertinax
    Commented May 12, 2020 at 21:07
  • @Pertinax "... the first column appears to be one row shorter than all the other ones." I get a balanced output. Which version of supertabular and multicol do you use? Commented May 13, 2020 at 0:20
  • 1
    @Pertinax One table can have only one caption (the counter must stepped only once). It seems some text containing the caption shown at the top of every page or column is more like a task of \tablehead. Try \tablehead{\multicolumn{3}{c}{\itshape\makecell{Table \thetable\\ continued}} \\ \hline Tix & Lap & n\\ \hline} \tablecaption{Title}. PS: You can ask a new question for this kind of follow-up questions. Commented Jun 11, 2020 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .