如何最小化列宽并调整表格中的文本

如何最小化列宽并调整表格中的文本

我正在尝试找出一种方法来为我正在写的一篇论文提出一个半形式化的论点。似乎最好的方法是使用一个有三列的表格:左列是右对齐的前提数字,中间列是前提,右列是右对齐的前提标签/推理规则。目前我的代码输出以下内容,这与我想要的非常接近:

在此处输入图片描述

我想做几个更改,但不知道该怎么做。首先,我希望中间一列的文本对齐。其次,我希望左右两列的宽度达到必要的最小值。

以下是 MWE:

\documentclass[12pt]{article}

\usepackage{tabularx}
\usepackage{array}
\usepackage{baskervillef} %font
\usepackage[T1]{fontenc} %font
\usepackage{mathrsfs} % fancy maths latters
\usepackage[margin=30mm]{geometry} %changes margins

\begin{document}

\begin{table}[h!]
    \begin{center}
        \begin{tabularx}{\textwidth}{ 
                >{\raggedleft\arraybackslash}p{.05\textwidth}
                >{\raggedright\arraybackslash}p{.68\textwidth}
                >{\raggedleft\arraybackslash}p{.2\textwidth}}
            (1) & If $\mathscr{X}_{1}$ is correct, then: If $\Gamma \models_{\mathscr{X}_{1}} \varphi$ then $O(Bs\Gamma \supset Bs\varphi)$ & (Normativity)\\
            (2) & If $\mathscr{X}_{2}$ is correct, then: If $\Gamma \not\models_{\mathscr{X}_{2}} \varphi$ then $O\neg(Fs\varphi m)$ & (Normativity)\\
            (3) & $\mathscr{X}_{1}$ and $\mathscr{X}_{2}$ are correct & (Pluralism)\\
            (4) & If $\Gamma \models_{\mathscr{X}_{1}} \varphi$ then $O(Bs\Gamma \supset Bs\varphi)$ & (1,3, MP)\\
            (5) & If $\Gamma \not\models_{\mathscr{X}_{2}} \varphi$ then $O\neg(Fs\varphi m)$ & (2,3, MP)\\
            (6) & If $O(Bs\varphi)$ and \textit{m} is a reliable method by which \textit{s} can form the belief that $\varphi$, then $\neg O\neg(Fs\varphi m)$ & (\textit{Transmission})\\
            (7) & $\Gamma \models_{\mathscr{X}_{1}} \varphi$ & (Pluralism)\\
            (8) & $\Gamma \not\models_{\mathscr{X}_{2}} \varphi$ & (Pluralism)\\
            (9) & $O(Bs\Gamma)$ & (\textit{Ex hypothesi})\\
            (10) & \textit{m} is a reliable method by which \textit{s} can form the belief that $\varphi$ & (Pluralism)\\
            (11) & $O(Bs\Gamma \supset Bs\varphi)$ & (4,7, MP)\\
            (12) & $O(Bs\varphi)$ & (9,11, MP)\\
            (13) & $\neg O\neg(Fs\varphi m)$ & (6,10,12, MP)\\
            (14) & $O\neg(Fs\varphi m)$ & (5,8, MP)\\
            (15) & $\mathscr{X}_{1}$ and $\mathscr{X}_{2}$ are not correct & (3,13,14, RAA)
        \end{tabularx}
    \end{center}
\end{table}

\end{document}

答案1

如果希望文本对齐,请不要使用>{\raggedright}中间列的指令。要最小化其他列,请使用标准r说明符。以下是一段代码,我擅自将最右边的列左对齐,因为在我看来,这样看起来更好:

\documentclass[12pt]{article}

\usepackage{tabularx}
\usepackage{array}
%\usepackage{baskervillef} %font
\usepackage[T1]{fontenc} %font
\usepackage{mathrsfs} % fancy maths latters
\usepackage[margin=30mm]{geometry} %changes margins

\begin{document}

\begin{table}[h!]
 \centering
 \setlength{\extrarowheight}{3pt}
        \begin{tabularx}{\textwidth}{@{}rXl@{}}
            (1) & If $\mathscr{X}_{1}$ is correct, then: If $\Gamma \models_{\mathscr{X}_{1}} \varphi$ then $O(Bs\Gamma \supset Bs\varphi)$ & (Normativity)\\
            (2) & If $\mathscr{X}_{2}$ is correct, then: If $\Gamma \not\models_{\mathscr{X}_{2}} \varphi$ then $O\neg(Fs\varphi m)$ & (Normativity)\\
            (3) & $\mathscr{X}_{1}$ and $\mathscr{X}_{2}$ are correct & (Pluralism)\\
            (4) & If $\Gamma \models_{\mathscr{X}_{1}} \varphi$ then $O(Bs\Gamma \supset Bs\varphi)$ & (1,3, MP)\\
            (5) & If $\Gamma \not\models_{\mathscr{X}_{2}} \varphi$ then $O\neg(Fs\varphi m)$ & (2,3, MP)\\
            (6) & If $O(Bs\varphi)$ and \textit{m} is a reliable method by which \textit{s} can form the belief that $\varphi$, then $\neg O\neg(Fs\varphi m)$ & (\textit{Transmission})\\
            (7) & $\Gamma \models_{\mathscr{X}_{1}} \varphi$ & (Pluralism)\\
            (8) & $\Gamma \not\models_{\mathscr{X}_{2}} \varphi$ & (Pluralism)\\
            (9) & $O(Bs\Gamma)$ & (\textit{Ex hypothesi})\\
            (10) & \textit{m} is a reliable method by which \textit{s} can form the belief that $\varphi$ & (Pluralism)\\
            (11) & $O(Bs\Gamma \supset Bs\varphi)$ & (4,7, MP)\\
            (12) & $O(Bs\varphi)$ & (9,11, MP)\\
            (13) & $\neg O\neg(Fs\varphi m)$ & (6,10,12, MP)\\
            (14) & $O\neg(Fs\varphi m)$ & (5,8, MP)\\
            (15) & $\mathscr{X}_{1}$ and $\mathscr{X}_{2}$ are not correct & (3,13,14, RAA)
        \end{tabularx}
\end{table}

\end{document} 

在此处输入图片描述

答案2

如果进行\begin{tabularx}如下更改:

\begin{tabularx}{\textwidth}{rXr}

你得到:

  1. 第一列右对齐(r),其宽度由 LaTeX 计算为所需的最小值
  2. 居中对齐(X ),带自动换行
  3. 第三列右对齐(r),其宽度由 LaTeX 计算为所需的最小值

您可以使用传递给环境的第二个参数来控制表格的宽度{\textwidth},您可以将其乘以缩放因子;例如{0.75\textwidth}

您可能会看到列之间有“额外空间”,因为您强制将表格设置为\textwidth

另外,请考虑到列之间有一些水平空间。如果要删除它,只需执行

\begin{tabularx}{\textwidth}{r@{}X@{}r}

但结果可能不好看。列之间留一些空隙会更好。无论如何,你可以输入@{}你喜欢的长度,例如

\begin{tabularx}{\textwidth}{r@{\,}X@{\,}r}

相关内容