调整表格以适应页面,hbox 太大而无法容纳

调整表格以适应页面,hbox 太大而无法容纳

我已经看到了各种各样的例子,但是我无法相应地调整表格以适应页面,因为在尝试调整宽度或文本宽度方法时我继续收到错误:

\begin{table}[hb!]
\centering
\captiontargets for protein assay measurements}
\begin{tabular}{clcl}
Protein Feature & \multicolumn{1}{c}{Input Features}       & Target             &   \\ 
\cline{1-3}
Activity        & Sequence, Substrate, Enzyme Activity    &   \\
Expression      & Sequence, New Host                       & Protein Expression &   \\
Stability       & Sequence, Detergent     & Thermal Stability  &   \\
\cline{1-3}
\end{tabular}
\end{table}

答案1

两个版本使用booktabs水平线和tabularxtabular*来确保表格适合可用的文本宽度。

在此处输入图片描述

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

\begin{table}[hb!]
\centering
\caption{targets for protein assay measurements}
\begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xl}
\toprule
Protein Feature & Input Features                        & Target            \\ 
\midrule
Activity        & Sequence, Substrate, Enzyme Activity                       \\ \addlinespace
Expression      & Sequence, New Host                    & Protein Expression \\ \addlinespace
Stability       & Sequence, Detergent                   & Thermal Stability  \\
\bottomrule
\end{tabularx}
\end{table}


\begin{table}[hb!]
\centering
\setlength{\tabcolsep}{0pt}
\caption{targets for protein assay measurements}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lll}
\toprule
Protein Feature & Input Features                        & Target            \\ 
\midrule
Activity        & Sequence, Substrate, Enzyme Activity                       \\ 
Expression      & Sequence, New Host                    & Protein Expression \\ 
Stability       & Sequence, Detergent                   & Thermal Stability  \\
\bottomrule
\end{tabular*}
\end{table}


\end{document}

答案2

在此处输入图片描述

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tabularx}
\begin{document}
    \begin{table}[hb!]
        \centering
%       \captiontargets for protein assay measurements}
    \begin{tabularx}{\textwidth}{XXX}
        \multicolumn{1}{c}{Protein Feature} & \multicolumn{1}{c}{Input Features}       & \multicolumn{1}{c}{Target}   \\ 
        \cline{1-3}
        Activity        & Sequence, Substrate, Enzyme Activity    &   \\
        Expression      & Sequence, New Host                       & Protein Expression   \\
        Stability       & Sequence, Detergent     & Thermal Stability   \\
        \cline{1-3}
    \end{tabularx}
\end{table}
\end{document}

答案3

使用包booktabs中定义的表tabularray(版本2021P):

\documentclass{article}
\usepackage[skip=1ex]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
    \begin{table}[hb!]
\caption{Targets for protein assay measurements}
\label{tab:tblr}
\begin{booktabs}{
    colspec = @{} l X[l] l @{},
    rowsep=3pt
                }
    \toprule
Protein Feature & Input Features                        
                    & Target        \\
    \midrule
Activity        & Sequence, Substrate, Enzyme Activity
                    &               \\ 
Expression      & Sequence, New Host                    
                    & Protein Expression \\
Stability       & Sequence, Detergent                   
                    & Thermal Stability  \\
    \bottomrule
\end{booktabs}
    \end{table}
\end{document}

在此处输入图片描述

相关内容