如何格式化下表?

如何格式化下表?

以下是 MWE:

{
\textbf{EXACT VALUES OF TRIGONOMETRICAL RATIOS}\\\\
\renewcommand{\arraystretch}{1.5}
\setlength{\extrarowheight}{1.5pt}
\begin{tabular}{|c|c|c|c|c|}
    \hline 
    \multicolumn{2}{|c|}{Angle ($\theta$)} & &  &  \\ 
    Degrees & Radians & $\sin{\theta}$ & $\cos{\theta}$ & $\tan{\theta}$ \\ 
    \hline 
    $0^{\circ}$ & 0 & 0 & 1 & 0 \\ 
    \hline 
    $30^{\circ}$ & $\frac{\pi}{6}$ & $\frac{1}{2}$ & $\frac{\sqrt{3}}{2}$ & $\frac{1}{\sqrt{3}}$ \\ 
    \hline 
    $45^{\circ}$ & $\frac{\pi}{4}$ & $\frac{1}{\sqrt{2}}$ & $\frac{1}{\sqrt{2}}$ & 1 \\ 
    \hline 
    $60^{\circ}$ & $\frac{\pi}{3}$ & $\frac{\sqrt{3}}{2}$ & $\frac{1}{2}$ & $\sqrt{3}$ \\ 
    \hline 
    $90^{\circ}$ & $\frac{\pi}{2}$ & 1 & 0 & undefined \\ 
    \hline 
\end{tabular} 
}

实际表格:在此处输入图片描述

答案1

不知道您在寻找什么改进,但这可能是一个开始。我使用table环境来获得标题,array使用环境以便我不必输入$太多内容,使用固定列宽、booktabs命令和\multirow多行文本。

\documentclass{article}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{multirow}
\usepackage{array}
\newcolumntype{C}{>{\hfil$}p{1.5cm}<{$\hfil}} % https://tex.stackexchange.com/a/340000/156344
\begin{document}
\begin{table}
    \centering
    \caption{Exact values of trigonometrical ratios}
    \renewcommand{\arraystretch}{1.5}
    $\begin{array}{CCCCC}
    \toprule
    \multicolumn{2}{c}{\text{Angle ($\theta$)}} & \multirow{2}{*}{$\sin\theta$} & \multirow{2}{*}{$\cos\theta$} & \multirow{2}{*}{$\tan\theta$} \\ 
    \text{Degrees} & \text{Radians} & & & \\ 
    \midrule
    0^{\circ} & 0 & 0 & 1 & 0 \\ 
    30^{\circ} & \frac{\pi}{6} & \frac{1}{2} & \frac{\sqrt{3}}{2} & \frac{1}{\sqrt{3}}\\
    45^{\circ} & \frac{\pi}{4} & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 1 \\ 
    60^{\circ} & \frac{\pi}{3} & \frac{\sqrt{3}}{2} & \frac{1}{2} & \sqrt{3} \\ 
    90^{\circ} & \frac{\pi}{2} & 1 & 0 & \text{undefined} \\
    \bottomrule
    \end{array}$
    \label{tab:my_label}
\end{table}
\end{document}

在此处输入图片描述

答案2

我建议使用一些颜色和不同的布局:

\documentclass[a4paper, 10pt]{article}
\usepackage{bm, cmbright, calc}
\usepackage[dvipsnames,table]{xcolor} 
\renewcommand{\sfdefault}{cmbr}

\setlength\extrarowheight{1pt}                          % Move cell content down
\newcolumntype{C}{>{\centering\arraybackslash$}m{4ex}<{$}}
\newcolumntype{F}{>{\bfseries\centering\arraybackslash\columncolor{blue!15}}m{10ex}}
\newcolumntype{L}{@{}>{\rule{0pt}{4ex+1\tabcolsep}}m{0pt}@{}}   % To ensure equal row height 

 % Shortcuts
\newcommand*{\gray}{\cellcolor{gray!25}}
\newcommand*{\black}{\cellcolor{black}}
\newcommand*{\green}{\cellcolor{green!15}}

\arrayrulecolor{gray!15}                        % Light gray table rules

\begin{document}

\begin{tabular}{|F|*{5}{C|}L}                                                    
                    \firsthline%
                    \gray{}Degrees        % Gray cell over blue column, \rowcolor not possible to use
                    &   \green\kern0.4em0^{\circ}
                    &   \green30^{\circ}
                    &   \green45^{\circ}
                    &   \green60^{\circ}
                    &   \green90^{\circ}
                    &   \\
                    \hline%
                    \gray{}Radians
                    &   \green 0
                    &   \green\frac{\pi}{6}
                    &   \green\frac{\pi}{4}
                    &   \green\frac{\pi}{3}
                    &   \green\frac{\pi}{2}
                    &\\
                    \hline%
                    sin($\bm{\theta}$)
                    &   0
                    &   \frac{1}{2}
                    &   \frac{\sqrt 2}{2}
                    &   \frac{\sqrt 3}{2}
                    &   1
                    &\\
                    \hline%
                    cos($\bm{\theta}$)
                    &   1
                    &   \frac{\sqrt 3}{2}
                    &   \frac{\sqrt 2}{2}
                    &   \frac{1}{2}
                    &   0
                    &\\
                    \hline%
                    tan($\bm{\theta}$)
                    &   0
                    &   \frac{\sqrt 3}{3}
                    &   1
                    &   \sqrt 3
                    &   \black
                    &   \\
                    \hline%
        \end{tabular}
\end{document}

在此处输入图片描述

相关内容