2

I need to reproduce the following 2 layouts ( in landscape, if that matters ) involving just and only tables :

enter image description here

The first layout is just 1 long table that spans from the upper left to the bottom right corner, the entries of the table should auto-fit themselves for the right amount of vertical space . The important thing is that the entire page is being used .

The second problem is about the same but instead of having just 1 table I have more tables; and all the tables still need to auto-adjust together from the upper left corner to the bottom right one, but I would also like to tune the vertical spacing between each single table ( red space in the picture ) and the entries of each table should auto-fit the vertical space according to the space left by my adjustments .

I gave a rapid overview to the manual / docs / pdf of the tabularx package but I don't think it says anything about this kind of alignment and fitting so I'm looking for solutions and suggestions .

Note that I don't need anything else apart from the tabular data itself on this document, I don't need a title or other components of the documents ( footnotes, page numbers, etc etc ) , I can use the entire page just for the tables .

Thanks for the help .

  • 1
    Welcome to TeX.SX! Are you really talking about tables here or simply some layout elements? It would be helpful to (a) have some examples of the content and (b) see what you have tried so far. Maybe a package like tcolorbox with its tcbposter library could help you which provides very good "reflowing" facilities. – TeXnician Aug 19 '18 at 14:19
  • @TeXnician Thank you for the reply . I don't need any "extra" element like colors or lines, I just need to print tabular data that has 3-4 columns for each entry : a really minimal and simple layout . My problem is just about the alignment and find the right commands to keep the table on the whole page . Each entry in each column has small words and maybe small numerical values, nothing fancy . – user168698 Aug 19 '18 at 14:26
  • 2
    this remain me on four column document (like journal). i would not use table for this. just plain document. – Zarko Aug 19 '18 at 14:28
  • @Zarko can you show an example ? – user168698 Aug 19 '18 at 14:29
  • Have a look at the multicol package. – TeXnician Aug 19 '18 at 14:33
  • try \documentclass{article} \usepackage{geometry} \usepackage{multicol} \usepackage{lipsum} \begin{document} \begin{multicols}{4} \lipsum \end{multicols} \end{document} – Zarko Aug 19 '18 at 14:40
  • @Zarko I don't get how I can tell to latex to start from the upper left and use all the space up to the bottom right of the page . Your solution works, but doesn't have the vertical alignment that I'm looking for . – user168698 Aug 19 '18 at 14:52
  • @Zarko solved https://tex.stackexchange.com/questions/75295/multicols-use-all-vertical-space-before-moving-to-a-new-column ... so at this point I just create a table and work with multicols ? How to balance the vertical alignments in the second layout ( the red squares ) ? – user168698 Aug 19 '18 at 15:09

1 Answers1

1

Rather than using tables for this I would define a custom pics using tikz -- you can read all about pics in section 18.2 of the tikz manual (version 3.0.1a) -- and I'd then wrap everything into a custom macro so that the commands

\GrayTable{1,1,1,1}
\newpage

\RedTable{0.8,0.1,0.4,0.3}

would produce the two pages

enter image description here

The numbers in the comma separated list given to \GrayTable become the numbers printed in the table. In the \RedTable macro, the numbers give the "relative" height of the line in each column and the numbers in the table cells are automatically generated as in the MWE.

Using tikzpagenodes I have made the table fill the full "text area" of the page. There would probably be printing issues, but you could make the table fill the entire page by replacing all occurrences of current page header area with current page.

In fact, the macros below are slightly more general in that, within reason, they are not restricted to four columns and in exactly the same way produce (see the second example in the MWE below):

enter image description here

Here is the full code:

\documentclass[svgnames]{article}
\usepackage[a4paper, landscape]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}

\tikzset{
  gray cell/.style = {
      rectangle,
      fill=SlateGray,
      draw=LightGray,
      line width=2mm,
      anchor=north west,
      minimum height=\textheight,
      font=\Huge
  },
  pics/gray cells/.style args = {#1}{
     code = {
        % count the number of columns
        \foreach \x [count=\c, remember=\c as \C] in {#1} {};
        \foreach \x [count=\c, evaluate=\c as \r using {\c/\C}] in {#1} {
          \node[gray cell, minimum width=\textwidth/\C] at
            ($ (current page header area.north west)!\r!(current page header area.north east) $)
            {\x};
        }
     }
  },
  gray line/.style = {
    fill=LightGray,
    draw=LightGray,
  },
  red line/.style = {
    fill=Red,
    draw=Red,
  },
  pics/red cells/.style args = {#1}{
    code = {
      % count the number of columns

      \foreach \cell [count=\c, remember=\c as \C] in {#1} {};
      \foreach \x [count=\c, evaluate=\c as \r using {\c/\C},
                   evaluate=\c as \d using {int(\c+1)}] in {#1} {
        \node[gray cell, minimum width=\textwidth/\C] (RC\c) at
          ($ (current page header area.north west)!\r!(current page header area.north east) $){};
        \coordinate (RCL\c) at ($ (RC\c.north west)!\x!(RC\c.south west)+(0,1mm) $);
        \coordinate (RCR\c) at ($ (RC\c.north east)!\x!(RC\c.south east)-(0,1mm) $);
        \draw[gray line] (RCL\c) rectangle (RCR\c);
        \draw[red line] ($ (RCL\c)+(8mm,0) $) rectangle ($ (RCR\c)-(8mm,0) $);
        \node[font=\Huge] at ($ (-0.8,0.8) + (RCR\c.north east) $) {\c};
        \node[font=\Huge] at ($ (-0.8,0.8) + (RC\c.south east) $) {\d};
      }
    }
  }
}

\newcommand\GrayTable[1]{\tikz{\pic at (0,0) {gray cells={#1}};}}
\newcommand\RedTable[1]{\tikz{\pic at (0,0) {red cells={#1}};}}

\pagestyle{empty}
\begin{document}

\GrayTable{1,1,1,1}
\newpage

\RedTable{0.8,0.1,0.4,0.3}
\newpage

\GrayTable{1,2,3,4,5,6}
\newpage

\RedTable{0.8,0.1,0.5,0.7,0.4,0.3}

\end{document}
  • I don't think this is what the question is about. I believe it's about typesetting actual tabular data, spanning across pages. – Henri Menke Sep 19 '18 at 02:03