1

I have a two columns table with lot of records (not all yet but enough to trigger the issue) and use longtable to span on multiple pages, but the second part of the table got offsetted and not centered.

Making the document {article} instead of {book} and removing \chapter{} make the table perfectly aligned.

What can I be missing for the {book} to have the table aligned properly ?

two pages table

My relevant parts of the document is

\documentclass[a4paper,12pt]{book}
\overfullrule=2cm
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{array}

\begin{document}    

\chapter{IARU}
\section{xxx}
% xxx

\section{IARU Région 1}
% xxx
\begin{center}
    INTERNATIONAL AMATEUR RADIO UNION
\end{center}
\begin{center}
    REGION I
\end{center}

\begin{center}
    Site internet : \url{http://www.iaru-r1.org/}
\end{center}

\fontsize{9}{11}\selectfont{
\begin{longtable}[l]{p{.80\textwidth}p{.20\textwidth}}
    \toprule
    Nom        & Pays        \\
    \midrule
    \endhead % End of header, will repeated on each split

    ALBANIAN AMATEUR RADIO ASSOCIATION (AARA) &          Albania  \\
    AMATEURS RADIO ALGERIENS (ARA) & Algeria \\
    UNIO DE RADIOAFICIONATS ANDORRANS (URA) & Andorra \\
    FEDERATION OF RADIOSPORT OF THE REPUBLIC OF ARMENIA (FRRA) & Armenia \\
    OSTERREICHISCHER VERSUCHSSENDERVERBAND (OEVSV) & Austria \\
    FEDERATION OF RADIO SPORT OF REPUBLIC OF AZERBAIJAN (FRS) & Azerbaijan \\
    AMATEUR RADIO ASSOCIATION OF BAHRAIN (ARAB) & Bahrain \\
    BELARUS FEDERATION OF RADIOAMATEURS AND RADIOSPORTSMEN (BFRR) & Belarus \\
    KONINKLIJKE UNIE VAN DE BELGISCHE ZENDAMATEURS (UBA) & Belgium \\
    ASOCIJACIJA RADIOAMATERA BOSNE I HERCEGOVINE (ARABiH) & Bosnia \& Hercegovina \\
    BOTSWANA AMATEUR RADIO SOCIETY (BARS) & Bostwana \\
    BULGARIAN FEDERATION OF RADIO AMATEURS (BFRA) & Bulgaria \\
    ASSOCIATION DES RADIOAMATEURS DU BURKINA FASO (ARBF) & Burkina Faso \\
    ASSOCIATION BURUNDAISE DES AMATEURS RADIO ET TELEVISION (ABART) & Burundi \\
    ASSOCIATION DES RADIO AMATEURS DU CAMEROUN (ARTJ) & Cameroun \\
    UNION DES RADIOAMATEURS DU CONGO (URAC) & Congo \\
    ASSOCIATION DES RADIO AMATEURS IVOIRIENS (ARAI) & Cote d'Ivoire \\
    HRVATSKI RADIOAMATERSKI SAVEZ (HRS) & Croatia \\
    CYPRUS AMATEUR RADIO SOCIETY (CARS) & Cyprus \\
    CZECH RADIO CLUB (CRC) & Czech Republic \\
    ASSOCIATION DES RADIO AMATEURS DU CONGO (ARAC) & Democratic Republic of Congo \\
    EXPERIMENTERENDE DANSKE RADIOAMATOERER (EDR) & Denmark \\
    ASSOCIATION DES RADIOAMATEURS DE DJIBOUTI (ARAD) & Djibouti \\
    EGYPTIAN RADIO AMATEURS SOCIETY FOR DEVELOPMENT (ERASD) & Egypt \\
    ESTONIAN RADIO AMATEURS UNION (ERAU) & Estonia \\
    ETHIOPIAN AMATEUR RADIO SOCIETY (EARS) & Ethiopia \\
    FOROYSKIR RADIOAMATORAR (FRA) & Faroe Islands \\
    SUOMEN RADIOAMATOORILIITTO ry (SRAL) & Finland \\
    RADIOAMATERSKI SOJUZ NA MAKEDONIJA (RSM) & Former Yugoslav Republic of Macedonia \\
    UNION FRANCAISE DES RADIOAMATEURS (REF) & France \\
    ASSOCIATION GABONAISE DES RADIO AMATEURS (AGRA) & Gabon \\
    RADIO SOCIETY OF GAMBIA (RSTG) & Gambia \\
    NATIONAL ASSOCIATION OF RADIOAMATEURS OF GEORGIA (NARG) & Georgia \\
\end{longtable}}

\end{document}
2

TeX warns you

Overfull \hbox (24.0pt too wide) in alignment at lines 30--34

each column has \tabcolsep padding (6pt) on either side so with two columns your table is 24pt wider than the page.

\documentclass[a4paper,12pt]{book}
\overfullrule=2cm
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{hyperref}
\usepackage{array}

\newlength\mylength
\begin{document}    

\chapter{IARU}
\section{xxx}
% xxx

\section{IARU Région 1}
% xxx
\begin{center}
    INTERNATIONAL AMATEUR RADIO UNION
\end{center}
\begin{center}
    REGION I
\end{center}

\begin{center}
    Site internet : \url{http://www.iaru-r1.org/}
\end{center}

{\small
\setlength\mylength{\dimexpr\textwidth-4\tabcolsep}
\begin{longtable}[l]{>{\raggedright}p{.80\mylength}>{\raggedright\arraybackslash}p{.20\mylength}}
    \toprule
    Nom        & Pays        \\
    \midrule
    \endhead % End of header, will repeated on each split

    ALBANIAN AMATEUR RADIO ASSOCIATION (AARA) &          Albania  \\
    AMATEURS RADIO ALGERIENS (ARA) & Algeria \\
    UNIO DE RADIOAFICIONATS ANDORRANS (URA) & Andorra \\
    FEDERATION OF RADIOSPORT OF THE REPUBLIC OF ARMENIA (FRRA) & Armenia \\
    OSTERREICHISCHER VERSUCHSSENDERVERBAND (OEVSV) & Austria \\
    FEDERATION OF RADIO SPORT OF REPUBLIC OF AZERBAIJAN (FRS) & Azerbaijan \\
    AMATEUR RADIO ASSOCIATION OF BAHRAIN (ARAB) & Bahrain \\
    BELARUS FEDERATION OF RADIOAMATEURS AND RADIOSPORTSMEN (BFRR) & Belarus \\
    KONINKLIJKE UNIE VAN DE BELGISCHE ZENDAMATEURS (UBA) & Belgium \\
    ASOCIJACIJA RADIOAMATERA BOSNE I HERCEGOVINE (ARABiH) & Bosnia \& Hercegovina \\
    BOTSWANA AMATEUR RADIO SOCIETY (BARS) & Bostwana \\
    BULGARIAN FEDERATION OF RADIO AMATEURS (BFRA) & Bulgaria \\
    ASSOCIATION DES RADIOAMATEURS DU BURKINA FASO (ARBF) & Burkina Faso \\
    ASSOCIATION BURUNDAISE DES AMATEURS RADIO ET TELEVISION (ABART) & Burundi \\
    ASSOCIATION DES RADIO AMATEURS DU CAMEROUN (ARTJ) & Cameroun \\
    UNION DES RADIOAMATEURS DU CONGO (URAC) & Congo \\
    ASSOCIATION DES RADIO AMATEURS IVOIRIENS (ARAI) & Cote d'Ivoire \\
    HRVATSKI RADIOAMATERSKI SAVEZ (HRS) & Croatia \\
    CYPRUS AMATEUR RADIO SOCIETY (CARS) & Cyprus \\
    CZECH RADIO CLUB (CRC) & Czech Republic \\
    ASSOCIATION DES RADIO AMATEURS DU CONGO (ARAC) & Democratic Republic of Congo \\
    EXPERIMENTERENDE DANSKE RADIOAMATOERER (EDR) & Denmark \\
    ASSOCIATION DES RADIOAMATEURS DE DJIBOUTI (ARAD) & Djibouti \\
    EGYPTIAN RADIO AMATEURS SOCIETY FOR DEVELOPMENT (ERASD) & Egypt \\
    ESTONIAN RADIO AMATEURS UNION (ERAU) & Estonia \\
    ETHIOPIAN AMATEUR RADIO SOCIETY (EARS) & Ethiopia \\
    FOROYSKIR RADIOAMATORAR (FRA) & Faroe Islands \\
    SUOMEN RADIOAMATOORILIITTO ry (SRAL) & Finland \\
    RADIOAMATERSKI SOJUZ NA MAKEDONIJA (RSM) & Former Yugoslav Republic of Macedonia \\
    UNION FRANCAISE DES RADIOAMATEURS (REF) & France \\
    ASSOCIATION GABONAISE DES RADIO AMATEURS (AGRA) & Gabon \\
    RADIO SOCIETY OF GAMBIA (RSTG) & Gambia \\
    NATIONAL ASSOCIATION OF RADIOAMATEURS OF GEORGIA (NARG) & Georgia \\
\end{longtable}}

\end{document}
|improve this answer|||||
  • Thanks, I have seen the warns but not fully understood them. Should it be \newlength instead of \setlength ? Doesn't compile with set. Also \dimexpr doesn't seems to be usuable in vertical mode. – dashie Jul 21 '16 at 8:11
  • @dashie the code works without error as posted, you must have copied it incorrectly. \dimexpr is not usable in vertical mode but it is usable, as here in \setlength I would guess you have not copied the definition of \mylength which is in the document preamble. – David Carlisle Jul 21 '16 at 8:37
  • Exact I have missed the \newlength in the beginning, thanks you ! – dashie Jul 21 '16 at 8:43

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.