1

I am new to Latex. I built the following table and I have two problems. One is that raw number 7 in columns 1 and 2 has a width that is wider than the width of the other cells in the same columns. The second is that two equations in the lower part of the table (in column 3&4 in the merged raws from 7:9) are not centered. I have tried several things to correct the issues. I am now asking for help. How can these problems be corrected ? Thanks for any, and all, help.

Here is my Latex code, which has been made with use of 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 Answer 1

1

I'd exploit the fact that the objects in the first two columns have the same widths. For the split formulas I'd exploit their symmetries and flush them right.

\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}

It's still 80pt overfull with the standard text width, a problem that you should solve yourself in your document setup.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .