我的 Latex 表格存在问题

我的 Latex 表格存在问题

我是 Latex 的新手。我创建了下表,但遇到了两个问题。一是第 1 列和第 2 列中的原始数字 7 的宽度比同一列中其他单元格的宽度要宽。二是表格下半部分的两个方程式(7:9 合并的原始数据中的第 3 列和第 4 列)未居中。我尝试了几种方法来纠正这些问题。我现在寻求帮助。如何纠正这些问题?感谢所有人的帮助。

以下是我的 Latex 代码,使用 OverLeaf 制作:

\begin{table}[H]
\centering
\renewcommand{\arraystretch}{1.5}  % Adjust the height of the rows
\small  % Adjust the font size
\noindent
\setlength\tabcolsep{6pt}

% Calculate the maximum width for columns 1 and 2
\newlength{\maxwidth}
\settowidth{\maxwidth}{$\alpha_{2}<0, \, \alpha_{1}>0$}

\begin{tabular}{p{\maxwidth}|p{\maxwidth}|c|c} 
  angles sign & compare angles & $R$ & $z$ \\ \hline
  $\alpha_{2}>0, \, \alpha_{1}>0$ & $\alpha_{2}>\alpha_{1}$ & \multirow{5}{*}{%
    $\begin{aligned}
        R_{2} &= R_{1}+\frac{1}{2}c_{1}\sin(\alpha_{1}) 
        -\frac{1}{2}b_{1}\cos(\alpha_{1}) \\& +\frac{1}{2}c_{2}\sin(\alpha_{2})
        +\frac{1}{2}b_{2}\cos(\alpha_{2})
    \end{aligned}$} & \multirow{5}{*}{%
    $\begin{aligned}
        z_{2} &= z_{1}+\frac{1}{2}c_{1}\cos(\alpha_{1}) 
        -\frac{1}{2}b_{1}\sin(\alpha_{1}) \\ & +\frac{1}{2}c_{2}\cos(\alpha_{2}) +\frac{1}{2}b_{2}\sin(\alpha_{2})
    \end{aligned}$} \\ \cline{1-2}\cline{1-2}
  $\alpha_{2}>0, \, \alpha_{1}<0$ & $\alpha_{2}>\alpha_{1}$ & & \\ \cline{1-2}\cline{1-2}
   $\alpha_{2}<0, \, \alpha_{1}<0$ &  $\alpha_{2}>\alpha_{1}$ & & \\ \cline{1-2}\cline{1-2}
   $\alpha_{2}>0, \, \alpha_{1}>0$ & $\alpha_{2}=\alpha_{1}$ & & \\ \cline{1-2}\cline{1-2}
  $\alpha_{2}<0, \, \alpha_{1}<0$ & $\alpha_{2}=\alpha_{1}$ & & \\ \cline{1-4}
   $\alpha_{2}<0, \, \alpha_{1}>0$ &  $\alpha_{2}<\alpha_{1}$ & 
   $\begin{aligned}
        R_{2} &= R_{1}+\frac{1}{2}c_{1}\sin(\alpha_{1}) 
        -\frac{1}{2}b_{1}\cos(\alpha_{1})\\ & +\frac{1}{2}c_{2}\sin(\alpha_{2})+\frac{1}{2}b_{2}\cos(\alpha_{2})
    \end{aligned}$  & 
    $\begin{aligned}
        z_{2} &= z_{1}+\frac{1}{2}c_{1}\cos(\alpha_{1})+\frac{1}{2}b_{1}\sin(\alpha_{1})\\ &+\frac{1}{2}c_{2}\cos(\alpha_{2}) 
        -\frac{1}{2}b_{2}\sin(\alpha_{2})
    \end{aligned}$ \\ \cline{1-2}\cline{1-2}
  $\alpha_{2}>0, \, \alpha_{1}>0$ & $\alpha_{2}<\alpha_{1}$ & & \\ \cline{1-2}\cline{1-2}
  $\alpha_{2}<0, \, \alpha_{1}<0$&  $\alpha_{2}<\alpha_{1}$ & & \\ \hline
\end{tabular}
\renewcommand{\arraystretch}{1}  % Reset the array stretch for the rest of the document
\caption{Your Table Caption}
\end{table}

答案1

我会利用前两列中的对象具有相同宽度这一事实。对于拆分公式,我会利用它们的对称性并将它们向右对齐。

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering\small

%\setlength\tabcolsep{6pt}


\begin{tabular}{@{}cccc@{}}
\toprule
\multicolumn{2}{@{}c}{Angles} & $R$ & $z$ \\
\cmidrule(r){1-2}
sign & size \\
\midrule
\begin{tabular}{@{}c@{}}
  $\alpha_{2}>0, \, \alpha_{1}>0$ \\
  $\alpha_{2}>0, \, \alpha_{1}<0$ \\
  $\alpha_{2}<0, \, \alpha_{1}<0$ \\
  $\alpha_{2}>0, \, \alpha_{1}>0$ \\
  $\alpha_{2}<0, \, \alpha_{1}<0$
\end{tabular} &
\begin{tabular}{@{}c@{}}
  $\alpha_{2}>\alpha_{1}$ \\
  $\alpha_{2}>\alpha_{1}$ \\
  $\alpha_{2}>\alpha_{1}$ \\
  $\alpha_{2}=\alpha_{1}$ \\
  $\alpha_{2}=\alpha_{1}$
\end{tabular} &
$\begin{aligned}
  R_{2} = R_{1}+\frac{1}{2}c_{1}\sin(\alpha_{1})-\frac{1}{2}b_{1}\cos(\alpha_{1}) \\[0.5ex]
          +\frac{1}{2}c_{2}\sin(\alpha_{2})+\frac{1}{2}b_{2}\cos(\alpha_{2})
\end{aligned}$ &
$\begin{aligned}
  z_{2} = z_{1}+\frac{1}{2}c_{1}\cos(\alpha_{1})-\frac{1}{2}b_{1}\sin(\alpha_{1}) \\[0.5ex]
          +\frac{1}{2}c_{2}\cos(\alpha_{2}) +\frac{1}{2}b_{2}\sin(\alpha_{2})
\end{aligned}$ \\
\midrule
\addlinespace
\begin{tabular}{@{}c@{}}
  $\alpha_{2}<0, \, \alpha_{1}>0$ \\
  $\alpha_{2}>0, \, \alpha_{1}>0$ \\
  $\alpha_{2}<0, \, \alpha_{1}<0$
\end{tabular} &
\begin{tabular}{@{}c@{}}
  $\alpha_{2}<\alpha_{1}$ \\
  $\alpha_{2}<\alpha_{1}$ \\
  $\alpha_{2}<\alpha_{1}$
\end{tabular} &
$\begin{aligned}
  R_{2} = R_{1}+\frac{1}{2}c_{1}\sin(\alpha_{1})-\frac{1}{2}b_{1}\cos(\alpha_{1}) \\[0.5ex]
          +\frac{1}{2}c_{2}\sin(\alpha_{2})+\frac{1}{2}b_{2}\cos(\alpha_{2})
\end{aligned}$  &
$\begin{aligned}
  z_{2} = z_{1}+\frac{1}{2}c_{1}\cos(\alpha_{1})+\frac{1}{2}b_{1}\sin(\alpha_{1}) \\[0.5ex]
          +\frac{1}{2}c_{2}\cos(\alpha_{2})-\frac{1}{2}b_{2}\sin(\alpha_{2})
\end{aligned}$ \\
\addlinespace
\bottomrule
\end{tabular}

\caption{Your Table Caption}

\end{table}

\end{document}

它仍然超出标准文本宽度 80pt,您应该在文档设置中自行解决这个问题。

在此处输入图片描述

相关内容