如何在「tabularray」中同時保留「X」和「Q」樣式?

如何在「tabularray」中同時保留「X」和「Q」樣式?

tabularray非常有用,因為我需要做這些事情:

  1. 保持桌子盡可能寬\textwidth
  2. 我需要插入note{}表格的標題
  3. 表頭有兩個多字符,因此在一個單元格中分成幾行。在這種情況下,我需要將短頭保持在表格單元格的中間
  4. 保持數字小數點對齊

我所知:

  • 為了實現1,我可以使用tblror talltblrwithX格式
  • 為了實現2,我需要使用talltblr
  • 為了實現4,我可以talltblr使用Xandsi={}

但是,我要如何實現3talltblr?如果能將Qformat合併到 中talltblr,就可以同時實現這四個功能。

例如:

\documentclass{article}

\usepackage{tabularray}
\usepackage{siunitx}
\usepackage{romannum}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
\begin{table}[h]
  \begin{talltblr}
    [caption={Main component geographic information table\TblrNote{1}},
     label={tab:Main component geographic information table},
     note{1}={The data is obtained through satellite maps, and there are certain errors},
     note{2}={The latitude and longitude of the surface is the latitude and longitude of its centroid. There is a certain error in the measurement of latitude and longitude, for reference},
     note{3}={This length is the length in our study area}
    ]
    {colspec={
              X[1.5,r] X[1.3,c] X[1.3,c] X[c,si={table-format=4.2},0.8] X[c,si={table-format=4.2},0.8] X[c,si={table-format=1.2},0.8]
              } 
    }
    \toprule
      name  & latitude\TblrNote{2} & longitude &{gggggg\unit{\m}}  & gggggg\unit{\m} \TblrNote{3} &{{{area total\unit{\km\squared}}}}\\
    
         \midrule
      DongLake      &\ang{30;33;29.52}N &\ang{114;22;47.55}E &             &         & 12.74 \\
      dongtinglake     &\ang{30;33;12.71}N &\ang{114;20;46.87}E &         &         &0.12 \\
      great river      &\ang{30;33;33.66}N &\ang[minimum-integer-digits=2]{114;20;09.29}E & 1682.88&         &        \\
     bigbig lake      &\ang[minimum-integer-digits=2]{30;34;06.02}N &\ang{114;19;45.86}E &         &         & 2.74    \\
     inside the gate   &\ang{30;33;54.85}N &\ang{114;18;35.99}E &         &         & 0.06  \\
      new ditches     &\ang{30;35;33.19}N &\ang[minimum-integer-digits=2]{114;23;02.77}E & 977    &         &         \\
      west part of new gate   &\ang{30;35;26.31}N &\ang{114;21;43.67}E & 5213.77 &         &         \\
     luoai port   &\ang[minimum-integer-digits=2]{30;37;08.49}N &\ang{114;21;27.93}E & 3770.58 &         &         \\
qingling port     &\ang[minimum-integer-digits=2]{30;39;02.32}N &\ang{114;24;30.27}E &         &         & 0.13   \\
      from port to lake &\ang[minimum-integer-digits=2]{30;37;03.06}N &\ang{114;24;22.99}E & 345.15 &         &        \\
    east part of the gate   &\ang[minimum-integer-digits=2]{30;38;05.41}N &\ang{114;24;27.64}E &2926.08 &         &         \\
   Yangzi river     &\ang{30;37;43.29}N &\ang{114;20;58.87}E &         &         &         \\
      east part of the lake   &\ang{30;35;55.14}N &\ang{114;23;14.49}E & 1090.45 &         &         \\
      donghu port     &\ang{30;35;37.38}N &\ang{114;23;45.81}E & 7332.3 & \num{4614.19} &         \\
   west section of qingqing   &\ang[minimum-integer-digits=2]{30;38;01.20}N &\ang{114;24;11.10}E & 3449.86 &         &         \\
    new road   drainage station &\ang{30;33;55.17}N &\ang{114;18;48.14}E &         &         &         \\
nanjing drainage station  &\ang{30;33;52.23}N &\ang{114;18;29.72}E &         &         &         \\
      beijing pumping station   &\ang{30;37;22.34}N &\ang[minimum-integer-digits=2]{114;21;01.01}E &         &         &         \\
      guilin road gata   &\ang{30;37;19.42}N &\ang{114;20;57.23}E &         &         &       \\
      the last gate     &\ang{30;39;16.08}N &\ang{114;24;31.97}E &         &         &     \\     
    \bottomrule
\end{talltblr}
\end{table}
\end{document}

如何讓這張表實現這四個要求呢? 在此輸入影像描述

另一個問題:為什麼我不能替換ggggggLength?當我這樣做時,出現錯誤:Package siunitx Error: Invalid number 'e'.

答案1

編輯: ups,我沒有上傳最新版本的程式碼和圖像。現已更正。 So4ry 噪音...

作為起點:

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx} % libraries loads packages of the same names

\begin{document}
    \begin{table}[h]
    \sisetup{minimum-integer-digits=2}
\begin{talltblr}[
caption = {Main component geographic information table},
  label = {tab:Main component geographic information table},
remark{Note} = {The data are obtained through satellite maps, and there are certain errors},
     note{1} = {The latitude and longitude of the surface is the latitude and longitude of its centroid. There is a certain error in the measurement of latitude and longitude, for reference},
     note{2} = {This length is the length in our study area},
     note{3} = {Total area}
                ]{colsep = 3pt,
                  colspec = {@{} X[2,l, m, font=\linespread{0.84}\selectfont] r r
                            *{2}{X[c, si={table-format=4.2}]}
                                 X[c, si={table-format=2.2,
                                          minimum-integer-digits=1}]
                            @{}},
                   row{1} = {font=\small\bfseries, c, m}
    }
    \toprule
name        & latitude\TblrNote{1} 
                & longitude
                     & {{{gggggg \unit{\metre}}}}
                        & {{{gggggg\TblrNote{2} \unit{\metre}}}}
                            & {{{area\TblrNote{3} \unit{\km\squared}}}}\\

    \midrule
Dong Lake    & \ang{30;33;29.52}N 
                & \ang{114;22;47.55}E 
                    &   &   & 12.74         \\
Dongting Lake     
            & \ang{30;33;12.71}N 
                &\ang{114;20;46.87}E 
                    &   &   & 0.12          \\
Great river & \ang{30;33;33.66}N
                & \ang{114;20;09.29}E  
                    & 1682.88
                        &   &               \\
Big lake    & \ang{30;34;06.02}N        
                & \ang{114;19;45.86}E 
                    &   &   & 2.74          \\
inside the gate   
            & \ang{30;33;54.85}N 
                & \ang{114;18;35.99}E 
                    &   &   & 2.74          \\
new ditches & \ang{30;35;33.19}N    
                &\ang{114;23;02.77}E 
                    & 977    
                        &   &               \\
west part of new gate   
            & \ang{30;35;26.31}N 
                & \ang{114;21;43.67}E 
                    & 5213.77 
                        &   &               \\
Luoai port  & \ang{30;37;08.49}N    
                &\ang{114;21;27.93}E 
                    & 3770.58 
                        &   &               \\
qingling port     
            & \ang{30;39;02.32}N    
                &\ang{114;24;30.27}E 
                    &   &   & 0.13          \\
from port to lake 
            & \ang{30;37;03.06}N    
                & \ang{114;24;22.99}E 
                    & 345.15 
                        &   &               \\
east part of the gate   
            & \ang{30;38;05.41}N   
                & \ang{114;24;27.64}E 
                    & 2926.08 
                        &   &               \\
Yangzi river     
            & \ang{30;37;43.29}N 
                & \ang{114;20;58.87}E 
                    &   &   &               \\
east part of the lake   
            & \ang{30;35;55.14}N 
                & \ang{114;23;14.49}E 
                    & 1090.45 
                        &   &               \\
Donghu port & \ang{30;35;37.38}N 
                & \ang{114;23;45.81}E 
                    & 7332.3 
                        & 4614.19
                            &               \\
west section of qingqing   
            & \ang{30;38;01.20}N   
                & \ang{114;24;11.10}E
                    & 3449.86
                        &   &               \\
new road  drainage station 
            & \ang{30;33;55.17}N 
                &\ang{114;18;48.14}E 
                    &   &   &               \\
nanjing drainage station  
            & \ang{30;33;52.23}N 
                & \ang{114;18;29.72}E 
                    &   &   &               \\
Beijing pumping station   
            & \ang{30;37;22.34}N 
                &\ang{114;21;01.01}E    
                    &   &   &               \\
Guilin road gata   
            & \ang{30;37;19.42}N 
                &\ang{114;20;57.23}E 
                    &   &   &               \\
the last gate     
            & \ang{30;39;16.08}N 
                & \ang{114;24;31.97}E 
                    &   &   &               \\
    \bottomrule
\end{talltblr}
    \end{table}
\end{document}

在此輸入影像描述

筆記: 您確實(一次又一次)閱讀了軟體包文件。不僅閱讀,還嘗試不同的列格式設定。我的經驗告訴我,最好的學習方法是邊幹邊學。一開始有點耗時,但你很快就會弄清楚tabularray文法原理。

  • 選項c(中)、l(左)、r(右)和m(中)、t(上)b(下,最後三個在包中定義array)的含義與經典表中的相同。 - 除了提到的選項之外,tabularray再介紹三個選項:(h頭,在單元格頂部)、f(腳,在單元格底部)和j(對齊)。
  • 此選項可以單獨使用,也可以作為列類型的屬性X使用Q。例如:
    • X[c] 有寬度,由LaTeX計算且列內容是水平的
    • `X[2,l] 的寬度是兩倍,由 LaTeX 和左對齊列內容計算得出
    • Q[c, 2cm]Q[c, wd=2cm]定義寬度為 2cm 且內容水平居中的列
    • X[j]有合理的文本,需要時用連字號連接
    • 列的c行為與「經典」表格相同,列的寬度等於單元格中最長內容的寬度,且水平居中(其他選項也類似)
  • S列(定義為S列或例如,其中格式可以由表外部Q[c, si]定義,請參閱文件),此類 cel 的任何內容都必須符合經典表中的包,並用大括號括起來: \sisetupsiunitxsiunitx
    • 這是中斷table-format設置,
    • 停用內容含義的錯誤解釋(請記住,siunitx使用一些字母來指定數字,例如10e5mean 10 x 10^5
  • 由於tabularray不同的表格處理(使用l3exp),需要添加兩個大括號對(該siunitx要求在所有情況下都適用)。
  • tabularray包允許將行格式化為。舉些例子:
    • row{1} = {font=\bfseries}在第一行的所有行單元格中指定粗體文本,
    • 規定row{Z} = {font=\scfaily, c}小寫字母字體並將內容居中在表格的最後一行
  • ETC。

附錄: 您可能喜歡表格格式,它將行分組,例如將行分組為三行,並在它們之間插入一些額外的垂直空間。為此添加到序言中

  \ExplSyntaxOn
\NewChildSelector{eachthree}
  {
    \int_step_inline:nnnn {5}{3}{\l_tblr_childs_total_tl}
      { \clist_put_right:Nn \l_tblr_childs_clist {##1} }
  }
\ExplSyntaxOff

以及表序:

                   row{eachthree} = {abovesep=2ex},

考慮到這一添加,表格將丟失如下:

在此輸入影像描述

相關內容