如何調整長錶線寬

如何調整長錶線寬

我正在使用 classicthesis,並且有一個相當複雜的整體文檔,所以我無法真正發布 MWE(抱歉,對 LaTeX 相當奇怪)。我發布了一些軟體包,但我相信它們可能與表格相關。我的問題:我正在使用一個長表,它自動分佈在多個頁面上。一切工作正常,除了它超過文字的寬度(儘管使用 \linewidth 定義列)。

您能幫我確定我做錯了什麼或如何將表格寬度與線寬相符嗎?

萬分感謝!

\usepackage{calc, longtable, ltablex, booktabs,array, caption, enumitem}
\keepXColumns
\newcolumntype{x}[1]{>{\raggedright}p{#1}}

\begin{spacing}{.7}
\footnotesize
\begin{longtable}{x{0.35\textwidth} x{0.25\textwidth} x{0.4\textwidth}}
    \caption{Example table}\label{tab:example}  \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
    \tabularnewline
    \midrule
    \endfirsthead
    %%%%
    \caption{Example table (cont.)}  \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
    \tabularnewline
    \midrule
    \endhead
    %%%%
    \midrule[\heavyrulewidth]
    \multicolumn{3}{r}{\footnotesize\itshape Continue on the next page}
    \endfoot
    %%%%
    \bottomrule
    \endlastfoot
    %%%%

        Content & Content & Content   \tabularnewline
        Content & Content & Content   \tabularnewline

\end{longtable}
\end{spacing}

答案1

你有

\begin{longtable}
      {x{0.35\textwidth} x{0.25\textwidth} x{0.4\textwidth}}

但每列\tabcolsep兩側都有(預設為 6pt)空間,因此 36pt 太寬了。

嘗試

\begin{longtable}
      {@{}x{0.35\textwidth} x{\dimexpr 0.25\textwidth - 24pt\relax} x{0.4\textwidth}@{}}

所以你可以從兩側刪除填充@{}並在中間列中保存24pt(當然你可以以不同的方式分配它並從每列中刪除一些)

答案2

我會使用xltabular環境(包加載ltablex,但省去了添加的麻煩keepXColumns),規範>{\hsize)xx\hsize 具有不同寬度的列):

\documentclass{report}
\usepackage{classicthesis}
\usepackage{array, setspace}
\usepackage{calc, longtable,xltabular, booktabs, array, caption, enumitem}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}

\begin{document}

\mbox{}
\begin{spacing}{.7}
\footnotesize
\begin{xltabular}{\linewidth}{>{\hsize=1.05\hsize}X >{\hsize=0.75\hsize}X >{\hsize=1.20\hsize\arraybackslash}X}
    \caption{Example table}\label{tab:example} \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}} \\
    \midrule
    \endfirsthead
    %%%%
    \caption{Example table (cont.)} \\
    \toprule
    {\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}} \\
    \midrule
    \endhead
    %%%%
    \midrule[\heavyrulewidth]
    \multicolumn{3}{r}{\footnotesize\itshape Continue on the next page}
    \endfoot
    %%%%
    \bottomrule
    \endlastfoot
    %%%%
        Content & Content & Content \\
        Content & Content & Content
\end{xltabular}
\end{spacing}

\end{document} 

在此輸入影像描述

相關內容