2

i want to ask, how to fit the longtable in latex? My table made from latex table generator, and i already put the packgages that is required. I've try many option like using \resizebox or \adjustbox package, but nothing change. Here is my code. Would you like to help me to solve this problem. Thank you in advance.

% Please add the following required packages to your document preamble:
% \usepackage{multirow}
% \usepackage{longtable}
% Note: It may be necessary to compile the document several times to get a multi-page table to line up properly
\begin{longtable}[c]{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}
\caption{My caption}
\label{my-label}\\
\hline
\multirow{3}{*}{\textbf{ABCD}} & \multicolumn{1}{l|}{\multirow{3}{*}{\textbf{DEFG}}} & \multicolumn{10}{c|}{\textit{\textbf{ABCD}}} & \multicolumn{2}{c|}{\multirow{2}{*}{\textbf{F}}} \\ \cline{3-12}
 & \multicolumn{1}{l|}{} & \multicolumn{2}{c|}{\textit{\textbf{A}}} & \multicolumn{2}{c|}{\textbf{B}} & \multicolumn{2}{c|}{\textbf{C}} & \multicolumn{2}{c|}{\textbf{D}} & \multicolumn{2}{c|}{\textit{\textbf{E}}} & \multicolumn{2}{c|}{} \\ \cline{3-14} 
 & \multicolumn{1}{l|}{} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} \\ \hline
\endfirsthead
%
\multicolumn{14}{c}%
{{\bfseries Table \thetable\ continued from previous page}} \\
\hline
\multirow{3}{*}{\textbf{ABCD}} & \multicolumn{1}{l|}{\multirow{3}{*}{\textbf{DEFG}}} & \multicolumn{10}{c|}{\textit{\textbf{ABCD}}} & \multicolumn{2}{c|}{\multirow{2}{*}{\textbf{F}}} \\ \cline{3-12}
 & \multicolumn{1}{l|}{} & \multicolumn{2}{c|}{\textit{\textbf{A}}} & \multicolumn{2}{c|}{\textbf{B}} & \multicolumn{2}{c|}{\textbf{C}} & \multicolumn{2}{c|}{\textbf{D}} & \multicolumn{2}{c|}{\textit{\textbf{E}}} & \multicolumn{2}{c|}{} \\ \cline{3-14} 
 & \multicolumn{1}{l|}{} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} \\ \hline
\endhead
%
\multirow{5}{*}{\textbf{1}} & 3k & 0.51147 & 0.22235 & 0.49731 & 0.54498 & 0.5 & 0.46476 & 0.49219 & 0.23559 & 0.49048 & 0.47274 & 0.498 & 0.388 \\ \cline{2-14} 
 & 6k & 0 & 0 & 0.4939 & 0.353 & 0.48901 & 0.038357 & 0.49219 & 0.063279 & 0.48389 & 0.19879 & 0.392 & 0.131 \\ \cline{2-14} 
 & 9k & 0 & 0 & 0.48413 & 0.058022 & 0 & 0 & 0.44531 & 0.00058411 & 0 & 0 & 0.186 & 0.012 \\ \cline{2-14} 
 & 12k & 0 & 0 & 0.5 & 0.0017523 & 0 & 0 & 0 & 0 & 0 & 0 & 0.1 & 0 \\ \cline{2-14} 
 & 15k & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline
\multirow{5}{*}{\textbf{2}} & 100-3k & 0.50708 & 0.23014 & 0.49609 & 0.54751 & 0.50098 & 0.46067 & 0.48389 & 0.10923 & 0.49585 & 0.47352 & 0.497 & 0.364 \\ \cline{2-14} 
 & 100-6k & 0 & 0 & 0.49609 & 0.54751 & 0.48706 & 0.040693 & 0.49976 & 0.013435 & 0.50171 & 0.20775 & 0.397 & 0.162 \\ \cline{2-14} 
 & 100-9k & 0 & 0 & 0.48804 & 0.050039 & 0 & 0 & 0.0021973 & 0.0001947 & 0 & 0 & 0.098 & 0.01 \\ \cline{2-14} 
 & 50-6k & 0 & 0 & 0.50146 & 0.35319 & 0.47827 & 0.040109 & 0.49707 & 0.027064 & 0.49609 & 0.20444 & 0.395 & 0.125 \\ \cline{2-14} 
 & 25-6k & 0 & 0 & 0.50146 & 0.353 & 0.48267 & 0.037967 & 0.5 & 0.04595 & 0.49023 & 0.20191 & 0.395 & 0.128 \\ \hline
\multirow{11}{*}{\textit{\textbf{3}}} & 0 dB & 0.49097 & 0.28797 & 0.49658 & 0.48189 & 0.5 & 0.18516 & 0.50122 & 0.45386 & 0.49707 & 0.35514 & 0.497 & 0.353 \\ \cline{2-14} 
 & 10 dB & 0.50903 & 0.03602 & 0.49951 & 0.45424 & 0.49585 & 0.0023364 & 0.48926 & 0.36624 & 0.48608 & 0.11293 & 0.496 & 0.194 \\ \cline{2-14} 
 & 20 dB & 0 & 0 & 0.49878 & 0.36137 & 0 & 0 & 0.48926 & 0.13707 & 0.44849 & 0.0001947 & 0.287 & 0.1 \\ \cline{2-14} 
 & 30 dB & 0 & 0 & 0.49585 & 0.14174 & 0 & 0 & 0 & 0 & 0 & 0 & 0.099 & 0.028 \\ \cline{2-14} 
 & 40 dB & 0 & 0 & 0.49805 & 0.00038941 & 0 & 0 & 0 & 0 & 0 & 0 & 0.1 & 0 \\ \cline{2-14} 
 & 50 dB & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 60 dB & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 70 dB & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 80 dB & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 90 dB & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 100 dB & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline
\multirow{5}{*}{\textit{\textbf{4}}} & 8k & 0.48853 & 0.49708 & 0.50024 & 0.50526 & 0.49976 & 0.49844 & 0.48633 & 0.48579 & 0.48755 & 0.50312 & 0.492 & 0.498 \\ \cline{2-14} 
 & 11k & 0.49146 & 0.28563 & 0.50098 & 0.48189 & 0.49561 & 0.50019 & 0.49805 & 0.26382 & 0.49243 & 0.49844 & 0.496 & 0.406 \\ \cline{2-14} 
 & 16k & 0.48438 & 0.23598 & 0.48022 & 0.24864 & 0.49829 & 0.49727 & 0.49487 & 0.18964 & 0.47559 & 0.5 & 0.487 & 0.334 \\ \cline{2-14} 
 & 22k & 0 & 0 & 0.5 & 0.0017523 & 0 & 0 & 0 & 0 & 0 & 0 & 0.1 & 0 \\ \cline{2-14} 
 & 24k & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline
\multirow{4}{*}{\textbf{5}} & 1\% & 0.48218 & 0.79128 & 0.49658 & 0.64505 & 0.49048 & 0.73618 & 0.49219 & 0.75156 & 0.49414 & 0.74377 & 0.491 & 0.734 \\ \cline{2-14} 
 & 2\% & 0.48975 & 0.75019 & 0.48584 & 0.61293 & 0.49121 & 0.71748 & 0.48975 & 0.72839 & 0.49438 & 0.728 & 0.49 & 0.707 \\ \cline{2-14} 
 & 3\% & 0.49854 & 0.71106 & 0.49609 & 0.60164 & 0.5061 & 0.70249 & 0.50977 & 0.69996 & 0.48633 & 0.68769 & 0.499 & 0.681 \\ \cline{2-14} 
 & 4\% & 0.49609 & 0.67718 & 0.4873 & 0.58178 & 0.49146 & 0.69529 & 0.48926 & 0.67796 & 0.50195 & 0.6912 & 0.493 & 0.665 \\ \hline
\multirow{4}{*}{\textit{\textbf{6}}} & 1\% & 0.50244 & 0.59988 & 0.49487 & 0.53057 & 0.49243 & 0.49591 & 0.50171 & 0.58548 & 0.48853 & 0.49942 & 0.496 & 0.542 \\ \cline{2-14} 
 & 5\% & 0.4939 & 0.60066 & 0.48755 & 0.52804 & 0.49365 & 0.49669 & 0.49878 & 0.5734 & 0.49149 & 0.50195 & 0.493 & 0.54 \\ \cline{2-14} 
 & 10\% & 0.49878 & 0.60241 & 0.48096 & 0.52804 & 0.49365 & 0.49708 & 0.49634 & 0.57886 & 0.49268 & 0.50234 & 0.492 & 0.542 \\ \cline{2-14} 
 & 15\% & 0.51245 & 0.60845 & 0.50732 & 0.51967 & 0.46997 & 0.49766 & 0.49048 & 0.5773 & 0.50415 & 0.49805 & 0.497 & 0.54 \\ \hline
\multirow{4}{*}{\textit{\textbf{7}}} & 1\% & 0.4917 & 0.50117 & 0.49097 & 0.50156 & 0.49414 & 0.50195 & 0.4812 & 0.4889 & 0.48315 & 0.50428 & 0.488 & 0.5 \\ \cline{2-14} 
 & 2\% & 0.48975 & 0.51519 & 0.50659 & 0.50448 & 0.47681 & 0.50389 & 0.49121 & 0.50273 & 0.49487 & 0.49708 & 0.492 & 0.505 \\ \cline{2-14} 
 & 3\% & 0.50781 & 0.50195 & 0.49243 & 0.49883 & 0.49829 & 0.50545 & 0.4917 & 0.49416 & 0.49292 & 0.49007 & 0.497 & 0.498 \\ \cline{2-14} 
 & 4\% & 0.49585 & 0.49883 & 0.49878 & 0.49688 & 0.49512 & 0.50759 & 0.49976 & 0.49241 & 0.49316 & 0.50292 & 0.497 & 0.5 \\ \hline
\multirow{5}{*}{\textbf{8}} & 32k & 0.48926 & 0.25837 & 0.4939 & 0.41939 & 0.49829 & 0.49981 & 0.49219 & 0.22644 & 0.48071 & 0.49688 & 0.491 & 0.38 \\ \cline{2-14} 
 & 64k & 0.49609 & 0.0068146 & 0 & 0 & 0 & 0 & 0.49585 & 0.00077882 & 0 & 0 & 0.198 & 0.002 \\ \cline{2-14} 
 & 128k & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 192k & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \cline{2-14} 
 & 256k & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ \hline
\multirow{5}{*}{\textbf{9}} & 32k & 0.4978 & 0.0050623 & 0.49829 & 0.021612 & 0.49683 & 0.0025312 & 0.49951 & 0.0035047 & 0 & 0 & 0.398 & 0.007 \\ \cline{2-14} 
 & 64k & 0.4978 & 0.0050623 & 0.49829 & 0.021612 & 0.49683 & 0.0025312 & 0.49951 & 0.0035047 & 0 & 0 & 0.398 & 0.007 \\ \cline{2-14} 
 & 128k & 0.4978 & 0.0050623 & 0.49829 & 0.021612 & 0.49683 & 0.0025312 & 0.49951 & 0.0035047 & 0 & 0 & 0.398 & 0.007 \\ \cline{2-14} 
 & 192k & 0.4978 & 0.0050623 & 0.49829 & 0.021612 & 0.49683 & 0.0025312 & 0.49951 & 0.0035047 & 0 & 0 & 0.398 & 0.007 \\ \cline{2-14} 
 & 256k & 0.4978 & 0.0050623 & 0.49829 & 0.021612 & 0.49683 & 0.0025312 & 0.49951 & 0.0035047 & 0 & 0 & 0.398 & 0.007 \\ \hline
\multicolumn{2}{|c|}{\textbf{RATE}} & 0.269 & 0.197 & 0.372 & 0.262 & 0.298 & 0.211 & 0.329 & 0.204 & 0.255 & 0.231 & 0.305 & 0.221 \\ \hline
\end{longtable}

Here what its look like :

enter image description here

enter image description here

  • Welcome to TeX.SE. Please clarify what you mean by "fit[ting] the longtable in latex". E.g., are you trying to make it fit into a single page? If so, how big is the page, and how big (in terms of height and length) is the text block? Which font, and which font size, do you employ? – Mico Apr 17 at 6:47
  • Please always post a complete example so that people can run it, as it is we do not know the page size (nor have you said how you have defined \multirow although we might guess) – David Carlisle Apr 17 at 7:09
  • @DavidCarlisle - Thanks for this. I've deleted the standalone comment. – Mico Apr 17 at 7:17
  • you have not said what you want the output to look like, you have used longtable which is for multi-page tables, but the table does not have lots of rows but is very very wide, so do you want it to be in a very small font so it fits the page width or do you want to rotate it as a landscape table or ??? – David Carlisle Apr 17 at 7:42
  • Sorry for some incomplete information. All i want is to use table with multiple pages layout without cropping or some missing table. Is it possible? – Anchor Ryuujin Apr 17 at 7:47
2

(Remark: I wrote my answer using the code provided initially by the OP. The solution isn't affected materially if the headers are (more or less) of the form "ABCD".)

You haven't provided any information about the page size of your document, the width and height of the text block, or the font and the font size that are in use. As such, the following solution need not be successful in meeting your typographic needs.

I assume your main objective is to fit the 14-column table into the text block. If this assumption is correct, my main recommendation would be to switch from portrait mode to landscape mode. This may be achieved by embedding the longtable environment in a landscape environment. The second recommendation would be to reduce the value of the parameter \tabcolsep, which governs the amount of whitespace padding that's inserted to the left and right of each cell. The default value of this parameter is 6pt; in the code below, I've set its value to 4.5pt.

The following screenshot shows just the first few rows of the resulting table.

enter image description here

\documentclass[10pt]{article}
\usepackage[a4paper,margin=2.5cm]{geometry} % set margins appropriately
\usepackage{longtable,multirow}
\usepackage{array}    % for "\extrarowheight" macro
\usepackage{pdflscape}% for "landscape" environment
\begin{document}

\begin{landscape}
\setlength\extrarowheight{2pt}
\setlength\tabcolsep{4.5pt} % default: 6pt

\begin{longtable}[c]{|*{14}{c|}}
\caption{My caption}
\label{my-label}\\
\hline
\multirow{3}{*}{\textbf{}} & 
\multicolumn{1}{l|}{\multirow{3}{*}{\textbf{Parameter}}} & 
\multicolumn{10}{c|}{\textit{\textbf{}}} & 
\multicolumn{2}{c|}{\multirow{2}{*}{\textbf{}}} \\ 
\cline{3-12}
 & \multicolumn{1}{l|}{} & \multicolumn{2}{c|}{\textit{\textbf{}}} & 
 \multicolumn{2}{c|}{\textbf{}}  & \multicolumn{2}{c|}{\textbf{}}  & 
 \multicolumn{2}{c|}{\textbf{}}  & \multicolumn{2}{c|}{\textit{\textbf{}}} & 
 \multicolumn{2}{c|}{} \\ 
\cline{3-14}
 & \multicolumn{1}{l|}{} 
 & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} 
 & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} 
 & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} \\ 
\hline
\endfirsthead

\multicolumn{14}{c}{\bfseries Table \thetable, continued from previous page} \\[1ex]
\hline
\multirow{3}{*}{\textbf{}} & 
\multicolumn{1}{l|}{\multirow{3}{*}{\textbf{Parameter}}} & 
\multicolumn{10}{c|}{\textit{\textbf{}}} & 
\multicolumn{2}{c|}{\multirow{2}{*}{\textbf{}}} \\ 
\cline{3-12}
 & \multicolumn{1}{l|}{} & \multicolumn{2}{c|}{\textit{\textbf{}}} & 
 \multicolumn{2}{c|}{\textbf{}}  & \multicolumn{2}{c|}{\textbf{}}  & 
 \multicolumn{2}{c|}{\textbf{}}  & \multicolumn{2}{c|}{\textit{\textbf{}}} & 
 \multicolumn{2}{c|}{} \\ 
\cline{3-14}
 & \multicolumn{1}{l|}{} 
 & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} 
 & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} 
 & \textbf{BER A} & \textbf{BER B} & \textbf{BER A} & \textbf{BER B} \\ 
\hline
\endhead

\multicolumn{14}{r@{}}{\small\itshape continued on following page}\\
\endfoot

\hline
\endlastfoot

\multirow{5}{*}{\textbf{}} 
 &  3k & & & & & & & & & & & & \\ \cline{2-14}
 &  6k & & & & & & & & & & & & \\ \cline{2-14}
 &  9k & & & & & & & & & & & & \\ \cline{2-14}
 & 12k & & & & & & & & & & & & \\ \cline{2-14}
 & 15k & & & & & & & & & & & & \\ \hline
\multirow{5}{*}{\textbf{}} 
 & 100--3k & & & & & & & & & & & & \\ \cline{2-14}
 & 100--6k & & & & & & & & & & & & \\ \cline{2-14}
 & 100--9k & & & & & & & & & & & & \\ \cline{2-14}
 &  50--6k & & & & & & & & & & & & \\ \cline{2-14}
 &  25--6k & & & & & & & & & & & & \\ \hline
    \multirow{11}{*}{\textit{\textbf{}}} 
 &  0 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 10 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 20 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 30 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 40 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 50 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 60 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 70 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 80 dB & & & & & & & & & & & & \\ \cline{2-14}
 & 90 dB & & & & & & & & & & & & \\ \cline{2-14}
 &100 dB & & & & & & & & & & & & \\ \hline
    \multirow{5}{*}{\textit{\textbf{}}} 
 &  8k & & & & & & & & & & & & \\ \cline{2-14}
 & 11k & & & & & & & & & & & & \\ \cline{2-14}
 & 16k & & & & & & & & & & & & \\ \cline{2-14}
 & 22k & & & & & & & & & & & & \\ \cline{2-14}
 & 24k & & & & & & & & & & & & \\ \hline
    \multirow{4}{*}{\textbf{}} 
 & 1\% & & & & & & & & & & & & \\ \cline{2-14}
 & 2\% & & & & & & & & & & & & \\ \cline{2-14}
 & 3\% & & & & & & & & & & & & \\ \cline{2-14}
 & 4\% & & & & & & & & & & & & \\ \hline
    \multirow{4}{*}{\textit{\textbf{}}} 
 &  1\% & & & & & & & & & & & & \\ \cline{2-14}
 &  5\% & & & & & & & & & & & & \\ \cline{2-14}
 & 10\% & & & & & & & & & & & & \\ \cline{2-14}
 & 15\% & & & & & & & & & & & & \\ \hline
    \multirow{4}{*}{\textit{\textbf{Pitch Shifting}}} 
 & 1\% & & & & & & & & & & & & \\ \cline{2-14}
 & 2\% & & & & & & & & & & & & \\ \cline{2-14}
 & 3\% & & & & & & & & & & & & \\ \cline{2-14}
 & 4\% & & & & & & & & & & & & \\ \hline
    \multirow{5}{*}{\textbf{}} 
 &  32k & & & & & & & & & & & & \\ \cline{2-14}
 &  64k & & & & & & & & & & & & \\ \cline{2-14}
 & 128k & & & & & & & & & & & & \\ \cline{2-14}
 & 192k & & & & & & & & & & & & \\ \cline{2-14}
 & 256k & & & & & & & & & & & & \\ \hline
    \multirow{5}{*}{\textbf{}} 
 &  32k & & & & & & & & & & & & \\ \cline{2-14}
 &  64k & & & & & & & & & & & & \\ \cline{2-14}
 & 128k & & & & & & & & & & & & \\ \cline{2-14}
 & 192k & & & & & & & & & & & & \\ \cline{2-14}
 & 256k & & & & & & & & & & & & \\ \hline
 \multicolumn{2}{|c|}{\textbf{}} 
        & & & & & & & & & & & & \\

\end{longtable}
\end{landscape}
\end{document} 
  • I'm sorry, here the information about page setting of my doumment : \usepackage[paper=a4paper,headheight=0pt,left=4cm,top=3cm,right=3cm,bottom=3cm]{geometry} – Anchor Ryuujin Apr 17 at 8:14
  • Thank you for your answer Mico, but what if i don't use landscape layout? – Anchor Ryuujin Apr 17 at 8:20
  • @AnchorRyuujin - If you don't want to use landscape format, then I have no contructive suggestions to give. More precisely, the only suggestion I would give is to switch to the \tiny relative font size, but that would pretty much guarantee that the whole table becomes illegible to anybody not equipped with a magnifying glass. That's why I don't consider switching to \tiny to be a constructive suggestion. – Mico Apr 17 at 8:35
  • Ok, thank you Mico for all the suggestion. – Anchor Ryuujin Apr 17 at 8:41

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.