如何使表格宽度适合列的宽度?

如何使表格宽度适合列的宽度?

此表格应完美适合两列页面中的一列。但它显示的长度比列宽略长。我想让它正确适合。

    \begin{table}[h] 
    \renewcommand{\arraystretch}{1.3} 
    \caption{example}
    \label{an example}
    \centering 
    \hrule
    \begin{align*}
     &(\lambda x.xx)\lambda m \lambda n. m n &\\
     &(xx)[x:=\underline{\lambda m \lambda n. m n}] &\textbf{Step 2}  \\
     &(\underline{\lambda m_1 \lambda n_1. m_1 n_1})(\underline{\lambda m_2    \lambda n_2. m_2 n_2}) \\
     &(\lambda n_1. m_1 n_1)[m_1:=\lambda m_2 \lambda n_2. m_2 n_2] \\
     & \lambda n_1.((m_1 n_1)[m_1:=\underline{\lambda m_2 \lambda n_2. m_2 n_2}])   &\textbf{Step 5} \\
     & \lambda n_1.((m_1[m_1:=\underline{\lambda m_3 \lambda n_3. m_3 n_3}])(n_1[m_1:=\underline{\lambda m_4 \lambda n_4. m_4 n_4}]))  \\
     & \lambda n_1.((\lambda m_3 \lambda n_3. m_3 n_3)n_1)\\
     & \lambda n_1.((\lambda n_3. m_3 n_3)[m_3:=n_1]) \\
     & \lambda n_1.(\lambda n_3. ((m_3 n_3)[m_3:=\underline{n_1}])) &\textbf{Step 9} \\
    & \lambda n_1.(\lambda n_3.((m_3[m_3:=\underline{n_1}])(n_3[m_3:=\underline{n_1}]))) \\
    & \lambda n_1.(\lambda n_3.(n_1 n_3))
    \end{align*}
    \normalsize
    \hrule
    \end{table} 

有一张图片显示了我的问题,宽度比它应该的要大一点。(没有完全显示左边的列,但我想你可以看到)

在此处输入图片描述

我该怎么做?提前致谢

答案1

如果您可以将最长的方程式放入列中,那么这将有效。

\documentclass[twocolumn]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage{mathtools}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{table}[h] 
    \renewcommand{\arraystretch}{1.3} 
    \caption{example}
    \label{an example}
    \centering 
    \rule{\columnwidth}{.5pt}
    \begin{align*}
     &(\lambda x.xx)\lambda m \lambda n. m n &\\
     &(xx)[x:=\underline{\lambda m \lambda n. m n}] \tag{\textbf{Step 2}}  \\
     &(\underline{\lambda m_1 \lambda n_1. m_1 n_1})(\underline{\lambda m_2    \lambda n_2. m_2 n_2}) \\
     &(\lambda n_1. m_1 n_1)[m_1:=\lambda m_2 \lambda n_2. m_2 n_2] \\
     & \lambda n_1.((m_1 n_1)[m_1:=\underline{\lambda m_2 \lambda n_2. m_2 n_2}])   \tag{\textbf{Step 5}} \\
     & \lambda n_1.((m_1[m_1:=\underline{\lambda m_3 \lambda n_3. m_3 n_3}])
       (n_1[m_1:=\underline{\lambda m_4 \lambda n_4. m_4 n_4}]))  \\
     & \lambda n_1.((\lambda m_3 \lambda n_3. m_3 n_3)n_1)\\
     & \lambda n_1.((\lambda n_3. m_3 n_3)[m_3:=n_1]) \\
     & \lambda n_1.(\lambda n_3. ((m_3 n_3)[m_3:=\underline{n_1}])) \tag{\textbf{Step 9}} \\
    & \lambda n_1.(\lambda n_3.((m_3[m_3:=\underline{n_1}])(n_3[m_3:=\underline{n_1}]))) \\
    & \lambda n_1.(\lambda n_3.(n_1 n_3))
    \end{align*}
    \normalsize
    \hrule
    \end{table} 

\end{document}

演示

答案2

假设您使用标准文章类,如果将最长的方程分成两行,则可以将方程组放在一列宽度内:

\documentclass[twocolumn]{article}
\usepackage{mathtools}
\usepackage{lipsum}

    \begin{document}
\lipsum[2]
    \begin{table}[h]
    \renewcommand{\arraystretch}{1.3}
    \caption{example}
    \label{an example}
    \centering
    \hrule
    \begin{align*}
     &(\lambda x.xx)\lambda m \lambda n. m n &\\
     &(xx)[x:=\underline{\lambda m \lambda n. m n}] 
        &   \textbf{Step 1}  \\
     &(\underline{\lambda m_1 \lambda n_1. m_1 n_1})(\underline{\lambda m_2    \lambda n_2. m_2 n_2}) \\
     &(\lambda n_1. m_1 n_1)[m_1:=\lambda m_2 \lambda n_2. m_2 n_2] \\
     & \lambda n_1.((m_1 n_1)[m_1:=\underline{\lambda m_2 \lambda n_2. m_2 n_2}])
            & \textbf{Step 5} \\
     & \begin{multlined}[0.5\linewidth]
        \lambda n_1.((m_1[m_1 :=\underline{\lambda m_3 \lambda n_3. m_3 n_3}])\\
            (n_1[m_1 :=\underline{\lambda m_4 \lambda n_4. m_4 n_4}]))  
        \end{multlined} \\
     & \lambda n_1.((\lambda m_3 \lambda n_3. m_3 n_3)n_1)\\
     & \lambda n_1.((\lambda n_3. m_3 n_3)[m_3:=n_1]) \\
     & \lambda n_1.(\lambda n_3. ((m_3 n_3)[m_3:=\underline{n_1}])) 
                &   \textbf{Step 9} \\
    & \lambda n_1.(\lambda n_3.((m_3[m_3:=\underline{n_1}])(n_3[m_3:=\underline{n_1}]))) \\
    & \lambda n_1.(\lambda n_3.(n_1 n_3))
    \end{align*}
    \normalsize
    \hrule
    \end{table}
\end{document}    

在此处输入图片描述

编辑:解决方案中所有方程都在一行中,并且仍然有\footnotesize字体。借助tabular环境,可以将最长的方程突出到空间列中,并带有有关步骤的注释:

\documentclass[twocolumn]{article}
\usepackage{array}
\usepackage{lipsum}

    \begin{document}
\lipsum[2]
    \begin{table}[h]
    \renewcommand{\arraystretch}{1.3}
    \footnotesize
    \caption{example}
    \label{an example}
    \centering
    \hrule
    \begin{tabular}{@{} >{$}p{0.82\linewidth}<{$} >{\bfseries}l @{}}
(\lambda x.xx)\lambda m \lambda n. m n              &           \\
(xx)[x:=\underline{\lambda m \lambda n. m n}]       &   Step 2  \\
(\underline{\lambda m_1 \lambda n_1. m_1 n_1})
(\underline{\lambda m_2\lambda n_2. m_2 n_2})       &           \\
(\lambda n_1. m_1 n_1)[m_1:=\lambda m_2 \lambda n_2. m_2 n_2]   
                                                    &           \\
\lambda n_1.((m_1 n_1)[m_1:=\underline{\lambda m_2 \lambda n_2. m_2 n_2}])
                                                    &   Step 5  \\
\multicolumn{2}{@{}l}{$
\lambda n_1.((m_1[m_1 :=\underline{\lambda m_3 \lambda n_3. m_3 n_3}])
            (n_1[m_1 :=\underline{\lambda m_4 \lambda n_4. m_4 n_4}]))
                      $}                                        \\
\lambda n_1.((\lambda m_3 \lambda n_3. m_3 n_3)n_1) &           \\
\lambda n_1.((\lambda n_3. m_3 n_3)[m_3:=n_1])      &           \\
\lambda n_1.(\lambda n_3. ((m_3 n_3)[m_3:=\underline{n_1}]))
                                                    &   Step 9  \\
\lambda n_1.(\lambda n_3.((m_3[m_3:=\underline{n_1}])
            (n_3[m_3:=\underline{n_1}])))           &           \\
\lambda n_1.(\lambda n_3.(n_1 n_3))                 &
    \end{tabular}
    \normalsize
    \hrule
    \end{table}
\end{document}  

在此处输入图片描述

相关内容