如何设置列宽使得垂直尺寸尽可能小?

如何设置列宽使得垂直尺寸尽可能小?

例如,在 Word 中,如果两列的线宽各为 50%,则会产生:

enter image description here

调整完列宽后,我可以最小化表格的垂直尺寸:

enter image description here

有没有办法在 Latex 中实现这个?

编辑:MWE:

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabularx}

\begin{document}

\section*{Variables}

\begin{table}
    \centering
    \begin{tabularx}{\textwidth}{X|X}
         \toprule
         Variables & Treatment \\
         \midrule
         Independent & \\
         The angle between the ramp and the flat surface & The ramp is elevated by placing books underneath one end of the ramp, and the angle is fine-tuned using the screws in the feet. The angle is measured using the protractor, which is attached to the ramp. The angles used were 10, 15, 20, 25 and 30.\\
         \bottomrule
    \end{tabularx}
    \caption{List of variables and treatment}
    \label{tab:my_label}
\end{table}

\end{document}

答案1

tabulary比你更接近你需要的tabularx

enter image description here

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabulary}

\begin{document}

\section*{Variables}

\begin{table}
    \centering
    \begin{tabulary}{\textwidth}{L|L}
         \toprule
         Variables & Treatment \\
         \midrule
         Independent & \\
         The angle between the ramp and the flat surface & The ramp is elevated by placing books underneath one end of the ramp, and the angle is fine-tuned using the screws in the feet. The angle is measured using the protractor, which is attached to the ramp. The angles used were 10, 15, 20, 25 and 30.\\
         \bottomrule
    \end{tabulary}
    \caption{List of variables and treatment}
    \label{tab:my_label}
\end{table}

\end{document}

答案2

通常,所有Xatabularx都设置为相同的宽度。您可以使用来改变比例>{\hsize=0.45\hsize}X>{\hsize=1.55\hsize}X(确保所有 a 的总和\hsize等于列数X)。这需要对确切值进行一些手动调整。

另一个选择是使用tabulary下面第二个例子。

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabulary}
\usepackage{tabularx}

\begin{document}

\begin{table}
    \centering
    \begin{tabularx}{\textwidth}{@{}>{\hsize=0.35\hsize}X>{\hsize=1.65\hsize}X@{}}
         \toprule
         Variables & Treatment \\
         \midrule
         Independent & \\\addlinespace
         The angle between the ramp and the flat surface & The ramp is elevated by placing books underneath one end of the ramp, and the angle is fine-tuned using the screws in the feet. The angle is measured using the protractor, which is attached to the ramp. The angles used were 10, 15, 20, 25 and 30.\\
         \bottomrule
    \end{tabularx}
    \caption{List of variables and treatment}
    \label{tab:my_label1}
\end{table}


\begin{table}
    \centering
    \begin{tabulary}{\textwidth}{@{}LJ@{}}
         \toprule
         Variables & Treatment \\
         \midrule
         Independent & \\\addlinespace
         The angle between the ramp and the flat surface & The ramp is elevated by placing books underneath one end of the ramp, and the angle is fine-tuned using the screws in the feet. The angle is measured using the protractor, which is attached to the ramp. The angles used were 10, 15, 20, 25 and 30.\\
         \bottomrule
    \end{tabulary}
    \caption{List of variables and treatment}
    \label{tab:my_label}
\end{table}

\end{document}

enter image description here

相关内容