設定列的指定寬度

設定列的指定寬度

我正在嘗試製作一個表格,並希望將第一列設置為指定寬度,即 1 英寸。我看過一些相關的解決方案,但基本上都是使用\textwidth.因此我正在尋找是否有一些簡單的直接解決方案將寬度指定為 1 英吋。

以下是我的 MWE:

\documentclass[10pt]{article}
\usepackage[margin=0.8in]{geometry}

\begin{document}
    \begin{table}[h!]
        \begin{tabular}{ll}
            1, 1 & 2, 1\\
            1, 2 & 2, 2
        \end{tabular}
    \end{table}
\end{document}

答案1

您可以使用p{1in}代替l.

在下面的程式碼中,我新增了|用於取得用於標記列印列的垂直線。

請看代碼:

\documentclass[10pt]{article}
\usepackage[margin=0.8in]{geometry}

\begin{document}
    \begin{table}[h!]
        \begin{tabular}{|p{1in}|l|} % <====================================
            1, 1 & 2, 1\\
            1, 2 & 2, 2
        \end{tabular}
    \end{table}
\end{document}

及其結果:

產生的pdf文件

相關內容