0

How to resize this table in case if it is very long to fit the page ? Original question here: how to create a list of abbreviation

enter image description here

 \documentclass{article}
    \usepackage{tabularx}
    \usepackage{amsmath}
    \usepackage[table]{xcolor}
    \usepackage{tabularx, multirow, makecell, rotating} %
    \usepackage{enumitem}

        \begin{document}
        \begin{center}
    \bfseries
\settowidth\rotheadsize{List of Abbreviation/accronym}
\begin{tabularx}{\linewidth}{|c|>{\centering\arraybackslash}X|}
    \hline
\cellcolor{gray!30} Abbreviation & \cellcolor{gray!30} Explanation     \\
    \hline
\multirow[b]{2}{*}{USA}   
            & \cellcolor{blue!30}  United state of america
 \rule[-1em]{0pt}{2.5em} \\
    \cline{2-2}
%   & 
%   \rule[-1em]{0pt}{2.5em} \\
%    \cline{2-2}
    &    \rule[-1em]{0pt}{2.5em} \\
    \hline
        \multirow[b]{2}{*}{NY}   
            &  \cellcolor{blue!30} New york 
 \rule[-1em]{0pt}{2.5em} \\
    \cline{2-2}
%   & 
%   \rule[-1em]{0pt}{2.5em} \\
%    \cline{2-2}
    &     \rule[-1em]{0pt}{2.5em} \\
    \hline
\end{tabularx}
    \end{center}
    \end{document}
6
  • 3
    From the comments under your previous question, I guess you want to enable page breaking when the table gets too long to fit onto one page. This can be achieved using ltablex that combines the functionalities of longtable with thouse of tabularx.
    – leandriis
    Commented Apr 27, 2018 at 17:39
  • this is new question I want to keep long table in one page
    – Educ
    Commented Apr 27, 2018 at 17:44
  • by the way when i add or replace tabularx with 'ltablex' its gives me a lot of errors
    – Educ
    Commented Apr 27, 2018 at 17:46
  • 2
    @Educ Typically the first error is the important one. BTW, I find it hard to understand your question. Commented Apr 27, 2018 at 17:50
  • in what is this your question different from tex.stackexchange.com/questions/428898/…? this question seems to be duplicate to it ...
    – Zarko
    Commented Apr 28, 2018 at 3:22

1 Answer 1

1

Well although reading it in Spanish makes sense, and just to learn more I have tried to put a table that occupies the whole page and can continue in another, I used my preferred package to make nice tables tabu (it might be abandoned but it works well for me), to achieve modify the format of the sheet I used the package geometry, is what you want?

This is the result: enter image description here

And here the MWE:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass[a4paper,10pt]{article}
\usepackage[driver=pdftex]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tabu} % Use tabu for nice tables 
\usepackage[usenames,dvipsnames,table]{xcolor}

\usepackage{longtable}
\usepackage{tabularx}
\usepackage{array}
\usepackage[longtable]{multirow}
\usepackage{booktabs, array}
\usepackage{lipsum}

\definecolor{C0}{HTML}{D9D9D9}
\definecolor{C1}{HTML}{B3B2FF}
\renewcommand{\arraystretch}{1.3}

\begin{document}
\lipsum[1-6]    %dummy text for the firts page
\newpage
\pagestyle{empty} %clear head and foot
\newgeometry{%redefine the page dimmensions.
        textwidth=21cm,
        textheight=26cm,
        top=0cm,
        bottom=0cm,
        foot=0cm,
    }
    % Start preamble configurations, longtabu do not use table environment.
    \tabulinesep = 2mm % Separation between cell text and the table lines
    \tabulinestyle{1.5pt,C1} % define table lines style

    \begin{longtabu} to \linewidth {|X[1.1,c]|X[4]|} %check the manual xD
        %Start head definition 
        \tabucline - 
        \rowcolor{C0} % defines the color for all cells in the row
        \rowfont[c]{\bf}    % idem but with text
        Abbreviation & Explanation \\ \tabucline - \endhead % End head definition
        %start middle foot definition.
        \multicolumn{2}{l}{Continues in the next page...}  \endfoot
        %Start last foot definition.
        %NONE
        \endlastfoot
        %Here the table contents...
        \multirow{2}{*}{USA}
        &\cellcolor{C1}United state of america \\
        &\\ \tabucline -

        \multirow{2}{*}{NY}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{BAR}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{FOO}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{ASK}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{MWE}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{AST}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{LM}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{EST}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{NOR}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{MWE}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{AST}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{LM}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{EST}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{NOR}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{ADR}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{WEQ}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{HTTP}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{STI}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{FDA}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{RCT}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{NBC}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{HTTP}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{STI}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{FDA}
        &\cellcolor{C1}New york \\*  %\\* This is to force to split the table and separate properly; FDA goes to the next page
        &\\ \tabucline -

        \multirow{2}{*}{RCT}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{NBC}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

        \multirow{2}{*}{END}
        &\cellcolor{C1}New york \\
        &\\ \tabucline -

    \end{longtabu}

\restoregeometry % this restores the page at the preamble configuration.

\newpage{plain}
\lipsum[3-7] %dummy text for MWE
\end{document}

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