3

I have this table that it ok for the width but not for the height. How can I split into two different pages? I tried using longtable but I got so many errors.

I put an example of a long table taken on the net on this link

I also put the code here

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}

\title{Your Paper}

\author{You}

\date{\today}

\begin{document}
\maketitle

\begin{table}[h]
\begin{tabularx}{\linewidth}{|X|X|X|}

\hline
\textbf{Screen Charateristics} & \textbf{Qualifier} & \textbf{Description}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         \\ \hline
\multirow{4}{*}{Size}          & small              & Resources for small size screens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            \\ \cline{2-3} 
                               & normal             & Resources for normal size screens. (This is the baseline size.)                                                                                                                                                                                                                                                                                                                                                                                                                                              \\ \cline{2-3} 
                               & large              & Resources for large size screens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            \\ \cline{2-3} 
                               & xlarge             & Resources for extra-large size screens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      \\ \hline
\multirow{8}{*}{Density}       & ldpi               & Resources for low-density (ldpi) screens (~120dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                                          \\ \cline{2-3} 
                               & mdpi               & Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)                                                                                                                                                                                                                                                                                                                                                                                                                       \\ \cline{2-3} 
                               & hdpi               & Resources for high-density (hdpi) screens (~240dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                                         \\ \cline{2-3} 
                               & xhdpi              & Resources for extra-high-density (xhdpi) screens (~320dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                                  \\ \cline{2-3} 
                               & xxhdpi             & Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                           \\ \cline{2-3} 
                               & xxxhdpi            & Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi). Use this for the launcher icon only, see note above.                                                                                                                                                                                                                                                                                                                                                                                  \\ \cline{2-3} 
                               & nodpi              & Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.                                                                                                                                                                                                                                                                                                                            \\ \cline{2-3} 
                               & tvdpi              & Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a ``primary'' density group. It is mostly intended for televisions and most apps shouldn't need it-providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi. \\ \hline
Orientation                    & land               & Resources for screens in the landscape orientation (wide aspect ratio).                                                                                                                                                                                                                                                                                                                                                                                                                                      \\ \hline
                               & port               & Resources for screens in the portrait orientation (tall aspect ratio).                                                                                                                                                                                                                                                                                                                                                                                                                                       \\ \hline
\multirow{2}{*}{Aspect Ratio}  & long               & Resources for screens that have a significantly taller or wider aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration.                                                                                                                                                                                                                                                                                                                               \\ \cline{2-3} 
                               & notlong            & Resources for use screens that have an aspect ratio that is similar to the baseline screen configuration.                                                                                                                                                                                                                                                                                                                                                                                                    \\ \hline


\end{tabularx}
\caption{Resolution suffixes}
\label{table:ressuffixes}
\end{table}

\end{document}
3

The table seems easy to use as longtable :

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}

\title{Your Paper}

\author{You}

\date{\today}

\begin{document}
\maketitle


\begin{longtable}{|l|l|p{5.5cm}|}

\hline
\textbf{Screen Charateristics} & \textbf{Qualifier} & \textbf{Description}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         \\ \hline
\multirow{4}{*}{Size}          & small              & Resources for small size screens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            \\ \cline{2-3} 
                               & normal             & Resources for normal size screens. (This is the baseline size.)                                                                                                                                                                                                                                                                                                                                                                                                                                              \\ \cline{2-3} 
                               & large              & Resources for large size screens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                            \\ \cline{2-3} 
                               & xlarge             & Resources for extra-large size screens.                                                                                                                                                                                                                                                                                                                                                                                                                                                                      \\ \hline
\multirow{8}{*}{Density}       & ldpi               & Resources for low-density (ldpi) screens (~120dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                                          \\ \cline{2-3} 
                               & mdpi               & Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)                                                                                                                                                                                                                                                                                                                                                                                                                       \\ \cline{2-3} 
                               & hdpi               & Resources for high-density (hdpi) screens (~240dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                                         \\ \cline{2-3} 
                               & xhdpi              & Resources for extra-high-density (xhdpi) screens (~320dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                                  \\ \cline{2-3} 
                               & xxhdpi             & Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).                                                                                                                                                                                                                                                                                                                                                                                                                                           \\ \cline{2-3} 
                               & xxxhdpi            & Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi). Use this for the launcher icon only, see note above.                                                                                                                                                                                                                                                                                                                                                                                  \\ \cline{2-3} 
                               & nodpi              & Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.                                                                                                                                                                                                                                                                                                                            \\ \cline{2-3} 
                               & tvdpi              & Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a ``primary'' density group. It is mostly intended for televisions and most apps shouldn't need it-providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi. \\ \hline
Orientation                    & land               & Resources for screens in the landscape orientation (wide aspect ratio).                                                                                                                                                                                                                                                                                                                                                                                                                                      \\ \hline
                               & port               & Resources for screens in the portrait orientation (tall aspect ratio).                                                                                                                                                                                                                                                                                                                                                                                                                                       \\ \hline
\multirow{2}{*}{Aspect Ratio}  & long               & Resources for screens that have a significantly taller or wider aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration.                                                                                                                                                                                                                                                                                                                               \\ \cline{2-3} 
                               & notlong            & Resources for use screens that have an aspect ratio that is similar to the baseline screen configuration.                                                                                                                                                                                                                                                                                                                                                                                                    \\ \hline



\caption{Resolution suffixes}
\label{table:ressuffixes}
\end{longtable}

\end{document}
  • 1
    @Mico possibly I was watching Josephs's talk at UKTUG at the time... whatever feel free to fix:-) – David Carlisle Nov 29 '14 at 14:10
2

As you're looking to preserve the ability to set the width of the tabular material and to have three equally wide columns, you could proceed as follows: (i) Load the longtable, tabularx, and ltxtable packages, (ii) place the longtable material (which will contain column types defined by the tabularx package) in a separate file, and (iii) use the command \LTXtable{\textwidth}{<name of file containing the long table>} in the body of the document where you want the long table to be inserted.

Separately, because the columns are quite narrow, I would also like to suggest that you load the ragged2e package and define a new column type called, say, Y that typesets its material in a raggedright manner in order to avoid large interword gaps. I would also suggest that because the table will span more than one page, the table's caption be moved to the beginning instead of the end of the table.

In the code below, I use the filecontents package to make the code self-contained. In practice, you'd just place the material of the filecontents* environment in a file by itself.

enter image description here


enter image description here

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{longtable,tabularx,ltxtable,ragged2e}
\newcolumntype{Y}{>{\RaggedRight\arraybackslash}X}

\usepackage{filecontents}
\begin{filecontents*}{mylongtable.tex}
\begin{longtable}{|l|l|Y}  %% seems better than "{|Y|Y|Y|}"
\caption{Resolution suffixes} \label{table:ressuffixes}\\
\hline
\textbf{Screen Charateristics} & \textbf{Qualifier} & \textbf{Description} \\ 
\hline
\endfirsthead
\multicolumn{3}{l}{Table \ref{table:ressuffixes}: Resolution suffixes, continued}\\[1ex]
\hline
\textbf{Screen Charateristics} & \textbf{Qualifier} & \textbf{Description} \\ 
\hline
\endhead
\hline
\endfoot
Size & small  & Resources for small size screens.
\\ \cline{2-3}
& normal & Resources for normal size screens. (This is the baseline size.)
\\ \cline{2-3}
& large  & Resources for large size screens.
\\ \cline{2-3}
& xlarge & Resources for extra-large size screens.
\\ \hline
Density & ldpi & Resources for low-density (ldpi) screens (~120dpi).
\\ \cline{2-3}
& mdpi & Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
\\ \cline{2-3} 
& hdpi & Resources for high-density (hdpi) screens (~240dpi).
\\ \cline{2-3}
& xhdpi  & Resources for extra-high-density (xhdpi) screens (~320dpi).                                                                                
\\ \cline{2-3}
& xxhdpi & Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).                                                                                
\\ \cline{2-3} 
& xxxhdpi & Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi). Use this for the launcher icon only, see note above.
\\ \cline{2-3} 
& nodpi & Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density.
\\ \cline{2-3}
& tvdpi & Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a ``primary'' density group. It is mostly intended for televisions and most apps shouldn't need it-providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi. \\ \hline
Orientation & land & Resources for screens in the landscape orientation (wide aspect ratio).
\\ %% \cline{2-3}
& port  & Resources for screens in the portrait orientation (tall aspect ratio). 
\\ \hline
Aspect Ratio  & long & Resources for screens that have a significantly taller or wider aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration.
\\ \cline{2-3} 
& notlong  & Resources for use screens that have an aspect ratio that is similar to the baseline screen configuration.     
\end{longtable}
\end{filecontents*}

\begin{document}
\LTXtable{\textwidth}{mylongtable.tex}
\end{document}
1

A proposition that uses only one Xcolumn, and the booktabs and makecell packages, to improve the look of the table. I also loaded the siunitx package, defined a new unit, \dotperinch and derived a dpi command with one argument, the number of dots per inch:

\documentclass[a4paper]{article}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{ragged2e, textcomp}
\usepackage{amsmath, nccmath}
\usepackage{array, tabularx, ltablex, caption}
\usepackage{multirow}
\usepackage{makecell, booktabs}
\setlength\aboverulesep{1.ex}
\setlength\belowrulesep{1.ex}
\renewcommand\theadfont{\bfseries\upshape}
\renewcommand\theadalign{lc}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight\arraybackslash}m{#1}}
\newcommand\about{\ensuremath{\medmath{ ∼ \,}}}

\usepackage{siunitx}

\DeclareSIUnit{\dotperinch}{dpi}
\newcommand\dpi[1]{\SI{#1}{\dotperinch}}


\title{Your Paper}

\author{You}

\date{\today}
\begin{document}
\maketitle

{\setlength\defaultaddspace{2ex}
\begin{tabularx}{\linewidth}{>{\itshape}lr@{\qquad}X}
\toprule
\thead{Screen\\Characteristics} & \thead{Qualifier} & \thead{Description} \\
\midrule
Size & small & Resources for small size screens. \\
                              \addlinespace
                               & normal & Resources for normal size screens. (This is the baseline size.) \\
                               \addlinespace
                               & large & Resources for large size screens. \\
                               \addlinespace
                               & xlarge & Resources for extra-large size screens. \\
\cmidrule(lr){1-3}
Density & ldpi & Resources for low-density (ldpi) screens (\about\dpi{120}). \\
                              \addlinespace
    & mdpi & Resources for medium-density (mdpi) screens (\about\dpi{160}). (This is the baseline density.) \\
 \addlinespace
 & hdpi & Resources for high-density (hdpi) screens (\about\dpi{240}). \\
 \addlinespace
 & xhdpi & Resources for extra-high-density (xhdpi) screens (\about\dpi{320}). \\
 \addlinespace
 & xxhdpi & Resources for extra-extra-high-density (xxhdpi) screens (\about\dpi{480}). \\
 \addlinespace
 & xxxhdpi & Resources for extra-extra-extra-high-density (xxxhdpi) uses (\about\dpi{640}). Use this for the launcher icon only, see note above. \\
 \addlinespace
 & nodpi & Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen's density. \\
 \addlinespace
 & tvdpi & Resources for screens somewhere between mdpi and hdpi; approximately \dpi{213}. This is not considered a ``primary'' density group. It is mostly intended for televisions and most apps shouldn't need it-providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100\,px $ × $ 100\,px image for mdpi screens should be 133\,px $ × $ 133\,px for tvdpi. \\
 \cmidrule(lr){1-3}
 Orientation & land & Resources for screens in the landscape orientation (wide aspect ratio). \\
 \addlinespace
 & port & Resources for screens in the portrait orientation (tall aspect ratio). \\
 \cmidrule(lr){1-3}
 Aspect Ratio & long & Resources for screens that have a significantly taller or wider aspect ratio (when in portrait or landscape orientation, respectively) than the baseline screen configuration. \\
 \addlinespace
 & notlong & Resources for use screens that have an aspect ratio that is similar to the baseline screen configuration. \\ \bottomrule
                            \end{tabularx}
\captionof{table}{Resolution suffixes}
\label{table:ressuffixes}}

\end{document} 

enter image description here

enter image description here

  • If it weren't for the fact that you're using a (modified) m column type, I'd be tempted to get rid of all \cmidrules and all interior \midrules and replace them with \addlinespaces. Anyway, the use of the vertically-centered m column type is not innocuous in a multipage table, as the forlorn-looking word "Density" toward the bottom of the first page illustrates. – Mico Nov 29 '14 at 15:02
  • @Mico: Precisely, I wondered whether to remove at least the \cmidrule{2-3}. I'll follow you suggestion. As for the forlorn ‘Density’, I placed it there to show the group of rows continues on thefollowing page. Do you think it doesn't look too good? – Bernard Nov 29 '14 at 15:33
  • Much better without the \cmidrule{2-3} lines. :-) (I'd still place the headers in the first column -- "Size", "Density", etc -- at the top rather than in the middle of their respective cells.) By the way, for those who aren't familiar with the ltablex package, you may want to explain in a sentence or two what the \vspace{3cm} instruction works does this particular table. – Mico Nov 29 '14 at 16:12
  • @Mico: Thanks for the useful comments. I'll explain a little later, I don't have time at the moment. – Bernard Nov 29 '14 at 16:19
  • @Mico: with \addlinespace, I don't need \vpsace{3cm} any more. I also improved a bit, defining a \dpi macro with the siunits package. – Bernard Nov 29 '14 at 20:30

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.