0

I want to split my table on two pages by using the longtable package and I want also to print Continued on next page at the bottom of first part and continued from previous page at the top of the second part.

Here my .csv file:

index,          pdes,    epoch_JDTDB,                 tp_JDTDB,                     a_km,                        e,                    w_deg,                   ta_deg,                   ma_deg,                  n_deg/d
    1,    459872    ,      2459600.5,    0.245955429393969E+07,    0.150902180397680E+09,    0.700936137135535E-01,    0.444423490130398E+02,    0.509894719093894E+02,    0.449518800380460E+02,    0.972856801473429E+00
    2,    1991 VG   ,      2459600.5,    0.245965301734296E+07,    0.154448562453878E+09,    0.524440272062934E-01,    0.981969077945011E+02,    0.305901193619353E+03,    0.310657729272394E+03,    0.939542405344313E+00
    3,    2000 SG344,      2459600.5,    0.245967142235446E+07,    0.146215475380197E+09,    0.668906906224866E-01,    0.107259306095888E+03,    0.280186369328737E+03,    0.287658863754547E+03,    0.102000471918105E+01
    4,    2003 YN107,      2459600.5,    0.245973765703815E+07,    0.147913409318582E+09,    0.138963447919681E-01,    0.352070216744272E+03,    0.221439015133514E+03,    0.222501180674322E+03,    0.100249189670507E+01
    5,    2006 JY26 ,      2459600.5,    0.245950771201134E+07,    0.151137260433216E+09,    0.831296262363333E-01,    0.317110762865456E+03,    0.995403784006208E+02,    0.900588991605521E+02,    0.970587901094867E+00
    6,    2006 QQ56 ,      2459600.5,    0.245948919576395E+07,    0.147356242165350E+09,    0.455957054639189E-01,    0.132721216278857E+03,    0.116944610798197E+03,    0.112215042556733E+03,    0.100818303543359E+01
    7,    2006 RH120,      2459600.5,    0.245941700549627E+07,    0.154561655457568E+09,    0.245007640852704E-01,    0.612989647862820E+02,    0.172580928455976E+03,    0.172211683048000E+03,    0.938511397040527E+00
    8,    2008 KT   ,      2459600.5,    0.245953461409501E+07,    0.151258200465874E+09,    0.848608221871707E-01,    0.342764067883614E+03,    0.729900449651001E+02,    0.638713820818490E+02,    0.969424068668380E+00
    9,    2010 JW34 ,      2459600.5,    0.245945998807400E+07,    0.146787030932466E+09,    0.546959172169960E-01,    0.935305817647752E+02,    0.146104139983164E+03,    0.142486542927059E+03,    0.101405302017029E+01
   10,    2010 VQ98 ,      2459600.5,    0.245964817443899E+07,    0.153049476036059E+09,    0.271228099514851E-01,    0.278481297592747E+02,    0.312325623997152E+03,    0.314592246885651E+03,    0.952454901870152E+00
   11,    2011 BL45 ,      2459600.5,    0.245962311850242E+07,    0.155240281637318E+09,    0.209159127584399E-01,    0.290052626627032E+03,    0.338027420043348E+03,    0.338911319571078E+03,    0.932364134430259E+00
   12,    2011 MD   ,      2459600.5,    0.245970716287812E+07,    0.158025828430105E+09,    0.370354171841830E-01,    0.277534761279446E+03,    0.258982216976828E+03,    0.263169231962853E+03,    0.907820693971977E+00
   13,    2011 UD21 ,      2459600.5,    0.245959546831742E+07,    0.146394319819154E+09,    0.303901572781969E-01,    0.232201197921950E+03,    0.544610304321270E+01,    0.512293786480974E+01,    0.101813613801581E+01
   14,    2012 FC71 ,      2459600.5,    0.245944384209223E+07,    0.147753060700911E+09,    0.881238923958131E-01,    0.265651355261692E+02,    0.160837550414405E+03,    0.157304006796337E+03,    0.100412426689864E+01
   15,    2012 LA   ,      2459600.5,    0.245963284323666E+07,    0.155629244985498E+09,    0.215419232343968E-01,    0.313658884228480E+03,    0.328692090671317E+03,    0.329957307349960E+03,    0.928870940217809E+00
   16,    2012 TF79 ,      2459600.5,    0.245944560454553E+07,    0.157051642075687E+09,    0.382015078336360E-01,    0.105571935872503E+03,    0.144528321377656E+03,    0.141927692789605E+03,    0.916280553685583E+00
   17,    2013 BS45 ,      2459600.5,    0.245966822620292E+07,    0.148335781949418E+09,    0.837159284910235E-01,    0.234029113553501E+03,    0.283197371646046E+03,    0.292394810967472E+03,    0.998213189555839E+00
   18,    2013 GH66 ,      2459600.5,    0.245957636408977E+07,    0.157244355912090E+09,    0.445528650254918E-01,    0.234586878618380E+03,    0.240970375512773E+02,    0.220746219650596E+02,    0.914596622082036E+00
   19,    2013 RZ53 ,      2459600.5,    0.245958720069335E+07,    0.152067298076445E+09,    0.282800271702146E-01,    0.481464493894571E+02,    0.135328686885348E+02,    0.127899088014129E+02,    0.961697412888642E+00
   20,    2014 DJ80 ,      2459600.5,    0.245973661930365E+07,    0.146164397997344E+09,    0.670433424964364E-01,    0.358904031049864E+03,    0.216342051797593E+03,    0.221084883530397E+03,    0.102053942931091E+01
   21,    2014 QD364,      2459600.5,    0.245961356101330E+07,    0.147456947362464E+09,    0.415090568064656E-01,    0.183186617343013E+03,    0.345705713911763E+03,    0.346845595104856E+03,    0.100715040926994E+01
   22,    2014 WX202,      2459600.5,    0.245971504151086E+07,    0.154922831557422E+09,    0.587821123517639E-01,    0.980648925268380E+02,    0.246588855987646E+03,    0.252877189048973E+03,    0.935231342276537E+00
   23,    2015 JD3  ,      2459600.5,    0.245979799400818E+07,    0.158338861690838E+09,    0.788218128012126E-02,    0.103666631683835E+03,    0.181222876079030E+03,    0.181242267009019E+03,    0.905129905663600E+00
   24,    2015 XZ378,      2459600.5,    0.245972406905748E+07,    0.151814338975956E+09,    0.348266028265004E-01,    0.195766056131395E+03,    0.237455280394632E+03,    0.240866819389946E+03,    0.964102041686692E+00
   25,    2016 RD34 ,      2459600.5,    0.245960864268907E+07,    0.156518816441756E+09,    0.346884806290049E-01,    0.596425786776479E+00,    0.351958848081779E+03,    0.352500881593116E+03,    0.920963374354774E+00
   26,    2016 YR   ,      2459600.5,    0.245971110581366E+07,    0.153612415665988E+09,    0.673593654181797E-01,    0.160725976990122E+03,    0.247944300513107E+03,    0.255231513831913E+03,    0.947224044578286E+00
   27,    2017 BN93 ,      2459600.5,    0.245957590474879E+07,    0.156248041247550E+09,    0.514444699164082E-01,    0.339131486672269E+03,    0.251285655473790E+02,    0.227102325947081E+02,    0.923358432017030E+00
   28,    2017 FT102,      2459600.5,    0.245944372982097E+07,    0.155344111619768E+09,    0.589415445705560E-01,    0.246403161444080E+03,    0.149575212153502E+03,    0.146020372689207E+03,    0.931429520565171E+00
   29,    2017 HU49 ,      2459600.5,    0.245943859139239E+07,    0.145320084181079E+09,    0.550695712685786E-01,    0.315161871980752E+02,    0.168038875328450E+03,    0.166676230006317E+03,    0.102944638009368E+01
   30,    2018 PK21 ,      2459600.5,    0.245963016870613E+07,    0.147143192377718E+09,    0.809504986795553E-01,    0.169941300142329E+03,    0.324952037144644E+03,    0.330023526673465E+03,    0.101037346208080E+01
   31,    2018 PN22 ,      2459600.5,    0.245964001533153E+07,    0.148878145171218E+09,    0.441155460208655E-01,    0.163691635984829E+03,    0.317433045076963E+03,    0.320770624202571E+03,    0.992763423107931E+00
   32,    2019 FV2  ,      2459600.5,    0.245943637351810E+07,    0.157518620840742E+09,    0.222209832820111E-01,    0.261530436252940E+03,    0.150971465669649E+03,    0.149717649868919E+03,    0.912208975255747E+00
   33,    2019 GF1  ,      2459600.5,    0.245943235521925E+07,    0.148185016910306E+09,    0.483846257108554E-01,    0.330041500831176E+03,    0.169179721397270E+03,    0.168100553011994E+03,    0.999736966313342E+00
   34,    2019 KJ2  ,      2459600.5,    0.245949827968751E+07,    0.158158349636612E+09,    0.265217997937862E-01,    0.314100160250270E+03,    0.957108407828916E+02,    0.926811063618908E+02,    0.906679935775918E+00
   35,    2019 PO1  ,      2459600.5,    0.245976236466962E+07,    0.154980165970103E+09,    0.610251706846550E-01,    0.218594213105760E+03,    0.205557231128277E+03,    0.208703084314892E+03,    0.934712411548874E+00
   36,    2020 CD3  ,      2459600.5,    0.245964055404853E+07,    0.153927447429573E+09,    0.124119645956147E-01,    0.132237775849684E+03,    0.321293267894109E+03,    0.322176256449857E+03,    0.944317614311828E+00
   37,    2020 FA1  ,      2459600.5,    0.245942693660613E+07,    0.153683604227674E+09,    0.312125634356505E-01,    0.294791535604644E+03,    0.165222558829580E+03,    0.164289201946996E+03,    0.946565968120746E+00
   38,    2020 GE   ,      2459600.5,    0.245977309300938E+07,    0.150456297997289E+09,    0.394721369158331E-01,    0.290603400967119E+03,    0.190496156549044E+03,    0.191344761278848E+03,    0.977184645704984E+00
   39,    2020 HF4  ,      2459600.5,    0.245956204935473E+07,    0.152170464199802E+09,    0.242954013466628E-01,    0.698474821861645E+02,    0.386547752164136E+02,    0.369402879300588E+02,    0.960719584077720E+00
   40,    2020 HO5  ,      2459600.5,    0.245945224486759E+07,    0.148228891552893E+09,    0.235918887764843E-01,    0.341938234913160E+03,    0.149541883354307E+03,    0.148150334881044E+03,    0.999293127170340E+00
   41,    2020 MU1  ,      2459600.5,    0.245959361545908E+07,    0.153269851289492E+09,    0.410962934675716E-01,    0.965188360436188E+02,    0.710848612786732E+01,    0.654307763403493E+01,    0.950401444961766E+00
   42,    2020 RB4  ,      2459600.5,    0.245941602449114E+07,    0.155716321955468E+09,    0.318060742935540E-01,    0.275174554003549E+03,    0.171746079494735E+03,    0.171210227112294E+03,    0.928091908604127E+00
   43,    2020 VN1  ,      2459600.5,    0.245977387363191E+07,    0.146598676215311E+09,    0.639786305183112E-01,    0.300327912029078E+03,    0.183395099503827E+03,    0.183851006471909E+03,    0.101600797992378E+01
   44,    2020 WY   ,      2459600.5,    0.245941436932402E+07,    0.152573895524419E+09,    0.285563468083888E-01,    0.287367535530617E+03,    0.178214778516651E+03,    0.178110611366167E+03,    0.956911645141437E+00
   45,    2021 AK5  ,      2459600.5,    0.245960096976913E+07,    0.153883234554023E+09,    0.200291486058647E-01,    0.106272329030983E+03,    0.359537963721016E+03,    0.359556197536796E+03,    0.944724617674365E+00
   46,    2021 CZ4  ,      2459600.5,    0.245952260029562E+07,    0.156125208450099E+09,    0.127510194612455E-01,    0.276610968913450E+02,    0.734107432492926E+02,    0.720142521003868E+02,    0.924448336130501E+00
   47,    2021 GM1  ,      2459600.5,    0.245951518159400E+07,    0.146448569482789E+09,    0.251744356006535E-01,    0.422586455641710E+02,    0.897016401316863E+02,    0.868174896980165E+02,    0.101757046064737E+01
   48,    2021 LF6  ,      2459600.5,    0.245954841464668E+07,    0.146922210225726E+09,    0.376873564671643E-01,    0.748273000196580E+02,    0.562803660240619E+02,    0.527444328626688E+02,    0.101265383653239E+01
   49,    2021 RZ3  ,      2459600.5,    0.245971672035841E+07,    0.151247200249468E+09,    0.534340157484946E-01,    0.224932804594716E+03,    0.241821660186638E+03,    0.247320895670051E+03,    0.969529829982518E+00
   50,    2021 RG12 ,      2459600.5,    0.245950139770560E+07,    0.156344638609306E+09,    0.398352652964655E-01,    0.210277645516152E+02,    0.959750969086374E+02,    0.914221460756280E+02,    0.922502820234366E+00
   51,    2021 VH2  ,      2459600.5,    0.245960125240315E+07,    0.151499420286046E+09,    0.781099311214379E-01,    0.126995065106977E+03,    0.359146434545383E+03,    0.359272343623765E+03,    0.967109691573498E+00
   52,    2021 VX22 ,      2459600.5,    0.245945464036108E+07,    0.151091730973574E+09,    0.546343435510506E-01,    0.329828043095979E+03,    0.145319103606594E+03,    0.141633595750957E+03,    0.971026644544897E+00
   53,    2022 BY39 ,      2459600.5,    0.245953050383236E+07,    0.150340931578298E+09,    0.790169133544520E-01,    0.435999438035180E+02,    0.771837059292549E+02,    0.684779261125277E+02,    0.978309647889179E+00


Here is my code:

\documentclass[11pt,twoside]{book}
\usepackage[%
            % chose this for a4
            a4paper,textwidth=15.5cm,textheight=26.0cm,%
            %
            inner=2.3cm,% 1.5cm,% 1cm,%
            %hcentering,%
            vcentering,%
            marginparwidth=2.2cm,% 2.8cm%,% 2.2cm,%
            %showframe%
            ]{geometry}
\usepackage{siunitx}
\usepackage{array}
\usepackage{csvsimple}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{makecell}
\usepackage{float}

\sisetup{
  round-mode=figures,
  round-precision = 3,
  exponent-product = {\hspace{-1pt}\times\hspace{-2pt}},
}


\begin{document}

\chapter{Title chapter}

\section{title section}
text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text.

\begin{table}[h]

  \caption{The table}
  \label{tab:label}
  \centering
  \begin{tabular}{
        @{} 
        c 
        l
        S[table-format=7.1]
        *3{S[table-format=1.3e1]}
        S[table-format=1.3e1]
        @{}
    }
    \toprule
      {\thead{idx.}}
    & {\thead[l]{pdes}}
    & {\thead{epoch\\ (JDTDB)}}
    & {\thead{a (km)}}
    & {\thead{e}}
    & {\thead{w (deg)}}
    & {\thead{ta (deg)}} \\
    \midrule
    \csvreader[
      late after line = \\,
    ]{Appendices/Appendix_B/NEA_filtered_data.csv}{}{%
      \csvcoli  & \csvcolii & \csvcoliii & \csvcoliv
      & \csvcolv & \csvcolvi & \csvcolvii
    }
    \bottomrule
  \end{tabular}
\end{table}

\end{document}

The above code prints the table on a new page but I want that the table is printed after the text and continues on the new page. Can you help me, please?

1 Answer 1

2

You should use one of the long tables: longtable, xltabular or supertabular. The solution below is based on longtable; in the code, \endfirsthead, \endhead, \endfoot, and \endlastfoot are macros to indicate which lines of the table should appear on the first, subsequent or the last pages.

enter image description here

\documentclass[11pt,twoside]{book}
\usepackage[%
            % chose this for a4
            a4paper,textwidth=15.5cm,textheight=26.0cm,%
            %
            inner=2.3cm,% 1.5cm,% 1cm,%
            %hcentering,%
            vcentering,%
            marginparwidth=2.2cm,% 2.8cm%,% 2.2cm,%
            %showframe%
            ]{geometry}
\usepackage{siunitx}
\usepackage{array}
\usepackage{csvsimple}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{makecell}
\usepackage{float}
\usepackage{longtable}

\sisetup{
  round-mode=figures,
  round-precision = 3,
  exponent-product = {\hspace{-1pt}\times\hspace{-2pt}},
}


\begin{document}

\chapter{Title chapter}

\section{title section}
text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text, text.

\begin{longtable}{
    @{} 
    c 
    l
    S[table-format=7.1]
    *3{S[table-format=1.3e1]}
    S[table-format=1.3e1]
    @{}
}
\caption{The table} \\
\toprule
  {\thead{idx.}}
& {\thead[l]{pdes}}
& {\thead{epoch\\ (JDTDB)}}
& {\thead{a (km)}}
& {\thead{e}}
& {\thead{w (deg)}}
& {\thead{ta (deg)}} \\
\midrule \endfirsthead
\caption{The table \textit{(continued from previous page)}} \\
\toprule
  {\thead{idx.}}
& {\thead[l]{pdes}}
& {\thead{epoch\\ (JDTDB)}}
& {\thead{a (km)}}
& {\thead{e}}
& {\thead{w (deg)}}
& {\thead{ta (deg)}} \\
\midrule \endhead
\bottomrule
\multicolumn{7}{r@{}}{\textit{Continues on the next page ...}} \endfoot
\bottomrule \endlastfoot
\csvreader[
  late after line = \\,
]{NEA_filtered_data.csv}{}{%
  \csvcoli  & \csvcolii & \csvcoliii & \csvcoliv
  & \csvcolv & \csvcolvi & \csvcolvii
}
\end{longtable}
\end{document}
2
  • Thank you very much @Celdor. Can you kindly show how to manage the options of siunitx package to write the last two columns without using the current notation? For instance I want to get 44.10 instead of 0.441x10^2. I want to apply this change to the last two columns.
    – g_don
    Nov 23, 2022 at 23:42
  • 1
    It's enabled by the postfix e1 in formatting S. For instance, change S[table-format=1.3e1] to S[table-format=1.3].
    – Celdor
    Nov 24, 2022 at 8:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .