如何使用表格包调整整个表格和列的宽度?

如何使用表格包调整整个表格和列的宽度?

我尝试使用 tabular 包使右列相对于左列更宽(大约为 1/3)。我的代码出了问题,因为它使左列更宽,总宽度大于文本宽度。有什么帮助吗?

\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {Figures/} }

\usepackage[%
style=apa, backend=biber
]{biblatex}
\addbibresource{references.bib}

%eli
\usepackage{float}
\usepackage{lipsum}
\usepackage{subfig}
\usepackage{adjustbox}
\usepackage{tabularx,booktabs}
\usepackage{mathtools}
\usepackage{array}
\usepackage{dcolumn}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}
%\newcolumntype{P}{>{\raggedright\arraybackslash}X}
\setlength\tabcolsep{2pt}
\captionsetup{
    justification = centering
}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{booktabs}

\begin{document}
\begin{table}[tbh]
    \centering{\scriptsize
        \begin{tabular}{lm{0.3\textwidth}p{0.1\textwidth}}
            \hline
            Author  &Test Procedure \\ \hline
            Deere DU, Miller RP (\cite{deere1966engineering})& Record three readings along the length of NX-size core for each 451 rotation. Average a total of 24 readings,
            disregarding the erroneous readings.\\ \hline
            Young RP, Fowell RJ (\cite{young1978assessing})& Divide rock mass surface into grids and average the single impacts from each grid.\\ \hline
            ISRM (\cite{international1976engineering})& Record 20 rebound values from single impacts separated by at least a plunger diameter, and average the upper
            10 values.\\ \hline
            Goktan RM, Ayday C(\cite{goktan1993suggested})& Record 20 rebound values from single impacts separated by at least a plunger diameter. Reject outlier values by using Chauvenet’s criterion, and average the remaining readings.\\ \hline
            Soiltest & Record 15 rebound values from single impacts and average the highest 10. The maximum deviation from the
            mean should be less than 2.5.\\ \hline
            Matthews JA, Shakesby RA (\cite{matthews1984status})& 15 measurements on any sample. The mean of the rebound values are calculated and the five values deviating
            most from the mean are discarded.\\ \hline
            Kazi A, Al-Mansour ZR (\cite{kazi1980empirical}) & Record at least 35 rebound readings, drop the 10 lowest readings and average the remaining 25.\\ \hline
            Katz O. et al. (\cite{kazi1980empirical}) & Perform 32–40 individual impacts and average the upper $50\%$. \\ \hline
            Poole RW, Farmer IW (\cite{poole1980consistency}) & Select the peak rebound value from five continuous impacts at a point. Average the peaks of the three sets of
            tests conducted at three separated points. \\ \hline
            Hucka V (\cite{hucka1965rapid}) & Select the peak rebound value from 10 continuous impacts at a point. Average the peaks of the three sets of
            tests conducted at three separated points. \\ \hline
            GBG [41]& Record 12 readings taken in a diamond pattern at the test point. Discard the lowest and highest values to
            obtain a mean rebound number.\\ \hline
            USBR [43]& Ten readings at various locations on each surface. Discount the five lowest readings, and average the highest five.\\ \hline
            Sumner P and Nel W (\cite{sumner2002effect})& Take 15 readings at different points and discard five great outliers to obtain a mean value from the remaining 10 values.\\   
            \hline  
    \end{tabular}}
    \caption{Some recommended Schmidt hammer test procedures (from \cite{goktan2005comparative})}.
\end{table}

\end{document}

在此处输入图片描述

答案1

您可以将桌子布置成长桌,跨页显示。然后,您可以将表格设置为正常fontsize,并使用与周围文本相同的间距——除非您希望表格与周围文本明显不同。然后,​​您应该选择比小两个等级的字体normalfont

由于您的表格结构简单,因此您可以使用以下方法轻松计算列宽\dimexpr。您不需要表格型' 高级计算算法。由于我\tabcolsep使用 从每列中删除了一个@{},因此只需tabcolsep从每列中减去一个额外的值。我定义了两种新的列类型FL,分别为 1/3 和 2/3 文本宽度。我已经将第二列排版为对齐并使用微型以便有更好的换行。

如果你更喜欢表格型输入列,我建议板状的,这是长桌。它X除了在底部边距拆分长表格外,还提供列。(它兼容性非常好,您只需将三行代码从 更改为longtablexltabular然后更改对定义的注释,取消注释已注释的和%\newcolumntype的定义,并注释未注释的两个。)FL

我还在行之间添加了一些空间而不是水平规则,因为我发现这样的空间不太会造成干扰(个人品味)。

在此处输入图片描述在此处输入图片描述

\documentclass[11pt]{report}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{microtype}
\usepackage[%
style=apa, backend=biber
]{biblatex}
\addbibresource{references.bib}

\usepackage{array, xltabular}
\setlength\tabcolsep{0.5em}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{booktabs}
\usepackage[nodisplayskipstretch]{setspace}

%\newcolumntype{F}{>{\RaggedRight\arraybackslash\hsize=0.5\hsize}X} % First column (ragged right)
%\newcolumntype{L}{>{\hsize=1.5\hsize}X}                                                  % Last column (justified)


\newcolumntype{F}{>{\raggedright\arraybackslash}p{\dimexpr((0.333\textwidth)-\tabcolsep)}} % First column (ragged right)
\newcolumntype{L}{p{\dimexpr((0.667\textwidth)-\tabcolsep)}}                     % Last column (justified)

\onehalfspacing

\begin{document}
\begin{singlespacing}
\begin{xltabular}{\textwidth}{@{} FL @{}}
\caption{Some recommended Schmidt hammer test procedures (from Goktan2005)}\\
\toprule
Author  &Test Procedure \\ \midrule
\endfirsthead
\toprule
Author  &Test Procedure \\ \midrule
\endhead
\midrule
\multicolumn{2}{r@{}}{\small Continues\ldots}\\
\endfoot
\midrule
\multicolumn{2}{@{}l}{\ldots\ \small Continued}\\
\endlastfoot

Deere DU, Miller RP (Deere1966)& Record three readings along the length of NX-size core for each 451 rotation. Average a total of 24 readings, disregarding the erroneous readings.\\\addlinespace[6pt] 
            Young RP, Fowell RJ (Young1978)& Divide rock mass surface into grids and average the single impacts from each grid.\\
\addlinespace[6pt] 
            ISRM (International1976)& Record 20 rebound values from single impacts separated by at least a plunger diameter, and average the upper 10 values.\\ \addlinespace[6pt]  
            Goktan RM, Ayday C (Goktan1993)& Record 20 rebound values from single impacts separated by at least a plunger diameter. Reject outlier values by using Chauvenet’s criterion, and average the remaining readings.\\
\addlinespace[6pt]  
            Soiltest & Record 15 rebound values from single impacts and average the highest 10. The maximum deviation from the mean should be less than 2.5.\\
\addlinespace[6pt]
            Matthews JA, Shakesby RA (Matthews1984)& 15 measurements on any sample. The mean of the rebound values are calculated and the five values deviating most from the mean are discarded.\\
\addlinespace[6pt]  
            Kazi A, Al-Mansour ZR (Kazi1980) & Record at least 35 rebound readings, drop the 10 lowest readings and average the remaining 25.\\
\addlinespace[6pt]  
            Katz O. et al. (Kazi1980b) & Perform 32–40 individual impacts and average the upper $50\%$. \\ \addlinespace[6pt]  
            Poole RW, Farmer IW (Poole1980) & Select the peak rebound value from five continuous impacts at a point. Average the peaks of the three sets of tests conducted at three separated points. \\
\addlinespace[6pt]  
            Hucka V (Hucka1965) & Select the peak rebound value from 10 continuous impacts at a point. Average the peaks of the three sets of tests conducted at three separated points. \\
\addlinespace[6pt]  
            GBG [41]& Record 12 readings taken in a diamond pattern at the test point. Discard the lowest and highest values to obtain a mean rebound number.\\
\addlinespace[6pt]  
            USBR [43]& Ten readings at various locations on each surface. Discount the five lowest readings, and average the highest five.\\
\addlinespace[6pt]  
            Sumner P and Nel W (Sumner\&Nel2002)& Take 15 readings at different points and discard five great outliers to obtain a mean value from the remaining 10 values.\\
\addlinespace[6pt]
\end{xltabular}
\end{singlespacing}
\end{document}

答案2

我假设您正在寻求使用该\tabularx包及其同名环境。以下解决方案采用了以下想法:

  • 将整体宽度设置为\textwidth;用作X两列的列类型;并使第三列的宽度为第一列的三倍。(创建多个具有不同宽度的 X 型列时,请确保宽度总和等于 X 型列的数量。在下面的代码中,我们有 0.5+1.5=2=X 型列的数量。)附言:我通过反复试验得出了 1:3 的相对列宽比率。

  • 将(相对)字体大小从\scriptsize改为\small—— 你的读者会感激你的举动

  • 通过使用更少但间距适当的水平线,使表格看起来更加开放。请记住,空白在传达视觉分离感方面与线条一样有效。

在此处输入图片描述

\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\graphicspath{ {Figures/} }
%
%% not needed for this example:
%\usepackage[%
%style=apa, backend=biber
%]{biblatex}
%\addbibresource{references.bib}

\usepackage{float,lipsum,subfig}
\usepackage{adjustbox,tabularx,ragged2e}
\usepackage{amsmath,geometry,booktabs}
\usepackage{mathtools,array,dcolumn}
\newcolumntype{L}[1]{>{\RaggedRight\arraybackslash\hsize=#1\hsize}X}
\setlength\tabcolsep{4pt} % default: 6pt  % '2pt' is not exactly much

\usepackage[justification = centering]{caption}


\begin{document}
\begin{table}[tbh]
    % \centering % redundant
    %\scriptsize % barely legible
    \small

    \begin{tabularx}{\textwidth}{@{} L{0.5} L{1.5} @{}}
    \toprule
    Author & Test Procedure \\ 
    \midrule
    Deere DU, Miller RP (\cite{deere1966engineering})
    & Record three readings along the length of NX-size core for each 451 rotation. Average a total of 24 readings, disregarding the erroneous readings.\\ \addlinespace
    Young RP, Fowell RJ (\cite{young1978assessing})
    & Divide rock mass surface into grids and average the single impacts from each grid.\\ \addlinespace
    ISRM (\cite{international1976engineering})
    & Record 20 rebound values from single impacts separated by at least a plunger diameter, and average the upper 10 values.\\ \addlinespace
    Goktan RM, Ayday C (\cite{goktan1993suggested})
    & Record 20 rebound values from single impacts separated by at least a plunger diameter. Reject outlier values by using Chauvenet's criterion, and average the remaining readings.\\ \addlinespace
    Soiltest 
    & Record 15 rebound values from single impacts and average the highest 10. The maximum deviation from the
    mean should be less than 2.5.\\ \addlinespace
    Matthews JA, Shakesby RA (\cite{matthews1984status})
    & 15 measurements on any sample. The mean of the rebound values are calculated and the five values deviating most from the mean are discarded.\\ \addlinespace
    Kazi A, Al-Mansour ZR (\cite{kazi1980empirical}) 
    & Record at least 35 rebound readings, drop the 10 lowest readings and average the remaining 25.\\ \addlinespace
    Katz O. et al. (\cite{kazi1980empirical}) 
    & Perform 32--40 individual impacts and average the upper $50\%$. \\ \addlinespace
    Poole RW, Farmer IW (\cite{poole1980consistency}) 
    & Select the peak rebound value from five continuous impacts at a point. Average the peaks of the three sets of tests conducted at three separated points. \\ \addlinespace
    Hucka V (\cite{hucka1965rapid}) 
    & Select the peak rebound value from 10 continuous impacts at a point. Average the peaks of the three sets of tests conducted at three separated points. \\ \addlinespace
    GBG [41]
    & Record 12 readings taken in a diamond pattern at the test point. Discard the lowest and highest values to obtain a mean rebound number.\\ \addlinespace
    USBR [43]
    & Ten readings at various locations on each surface. Discount the five lowest readings, and average the highest five.\\ \addlinespace
    Sumner P and Nel W (\cite{sumner2002effect})
    & Take 15 readings at different points and discard five great outliers to obtain a mean value from the remaining 10 values.\\   
    \bottomrule  
    \end{tabularx}
    \caption{Some recommended Schmidt hammer test 
    procedures (from \cite{goktan2005comparative})}.
\end{table}

\end{document}

相关内容