1

How to adapt this table to break across page boundaries? 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}
4
  • test if adding package ltablex solve your problem.
    – Zarko
    Commented Apr 27, 2018 at 17:07
  • @Zarko okay wait for it
    – Educ
    Commented Apr 27, 2018 at 17:08
  • When i add 'ltablex' its works but i got 100 errors
    – Educ
    Commented Apr 27, 2018 at 17:14
  • see my answer below. it works without any error.
    – Zarko
    Commented Apr 27, 2018 at 17:32

1 Answer 1

2

package ltablex is combination of the packages tabularx end longtable. with it you can obtain:

enter image description here

\documentclass{article}
%\usepackage{tabularx} it is suficient to load it once (by ltablex)
\usepackage{amsmath}
\usepackage[table]{xcolor}
\usepackage{makecell, multirow, rotating, ltablex} 
              %  "ltablex" merge features of  `tabularx" and "longtable"
              % they are not need to be separately loaded
\keepXColumns % preserve `X` column features when content is shorter 
              % than cell determined by "tabularx" algorithm
\usepackage{enumitem}

        \begin{document}
%\begin{center}                                         % not needed
%\settowidth\rotheadsize{List of Abbreviation/acronym} % not needed, 
                                                        % you haven't rotated cells
\begingroup % added
\bfseries
\noindent%    added
\renewcommand\arraystretch{1.5}
\begin{tabularx}{\linewidth}{|c|
  >{\centering\arraybackslash}X|}
    \hline
\rowcolor{gray!30}
Abbreviation    &  Explanation                  \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{USA}
                &   \cellcolor{blue!30}
                    United State of America     \\
    \cline{2-2}
                &                               \\
    \hline
\multirow{2}{*}{NY}
                &   \cellcolor{blue!30}
                        New York                \\
    \cline{2-2}
                &                               \\
    \hline
\end{tabularx}
    \endgroup % added
\end{document}
1
  • Its works just fine I really appreciated your help
    – Educ
    Commented Apr 27, 2018 at 17:51

You must log in to answer this question.

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