That's very strange why the sum of the width of each column does not equal the total width of longtable. I have two tables:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{array}
\usepackage{titletoc}
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{longtable}
\begin{document}
\textwidth 15.95cm
\begin{center}
\begin{longtable}{
|p{0.25cm}
|p{4.6cm}
|p{2 cm}
|p{2.2cm}
|p{0.8cm}
|p{2.1cm}
|p{1.9cm}|
}
\multicolumn{7}{>{\centering}p{\textwidth}}{1
}\tabularnewline\hline
a & a & a & a & a & a & a
\tabularnewline\hline
\end{longtable}
\end{center}
\begin{center}
\begin{longtable}{
| >{\centering}p{13cm}
| >{\raggedright}p{9.cm}
| >{\raggedright}p{2.42cm}
| >{\raggedright}p{2.42cm} |
}
\multicolumn{4}{>{\centering}p{\textwidth}}{
2
}\tabularnewline\hline
a & a & a & a
\tabularnewline\hline
\end{longtable}
\end{center}
\end{docume
Two tables in the PDF exactly have same widths.
As marmot said the total width of a table should be
sum of columns + (n-1)*\arraycolsep
And how to know the value of \arraycolsep
?
More generally, how to make all the tables in the PDF has same widths? And what's the meaning of width \textwidth
in \multicolumn{7}{>{\centering}p{\textwidth}}
.
Moreover, when I decrease the width of some columns, the width of first line of table will decrease and the second line will not change; when I increase the width of some columns, both first and second lines will increase?
Best Answer
your tables has more issues.
\textwidth
(15.95 cm),\textwidth
, so it extend lats column that the width of the whole table is equal to\textwidth
in examples below are in determination of columns width considered
\tabcolsep
and\arrayrulewidth
.(red lines indicates border of text area).
the first and second table without of multi column cells have different widths. the purpose of the first table row is not clear. see if the third version of the first table gives what you like to achieve.