longtable 多页不居中

longtable 多页不居中

我有一个包含大量记录的两列表格(不是全部,但足以触发问题)并使用 longtable 跨越多页,但表的第二部分偏移了并且没有居中。

制作文档{article}代替{book}并删除\chapter{}可以使表格完美对齐。

{book}为了使表格正确对齐,我缺少什么?

两页表

我的文件的相关部分是

\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}

答案1

TeX 警告你

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

每列\tabcolsep两侧均有填充(6pt),因此,如果有两列,则表格比页面宽 24pt。

\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}

相关内容