我的 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,這是您應該在文件設定中自行解決的問題。

在此輸入影像描述

相關內容