表格中的平方根符号有问题:参见注释部分
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{indentfirst}
\usepackage[left=1.2in,right=1.2in,top=1in,bottom=1in]{geometry}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{enumitem}
\usepackage{array}
\usepackage{booktabs}
\usepackage{xcolor}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
\newcolumntype{C}{>{$\displaystyle}c<{$}}
%MAY HAVE PROBLEM COMPILING EXCEPT OVERLEAF \titleformat{\section}
{\normalfont\huge\bfseries}{\makebox[45pt][l]{\thesection}}{0pt}{}
%MAY HAVE PROBLEM COMPILING EXCEPT OVERLEAF \titleformat{\subsection}
{\normalfont\large\bfseries}{\makebox[45pt][l]{\thesubsection}}{0pt}{}
%MAY HAVE PROBLEM COMPILING EXCEPT OVERLEAF\setlength{\droptitle}{-4em}
\setlength{\parindent}{45pt}
\title{\Huge{\textbf{Mathematics Directory}}}
\author{\Large{Zhiyuan Liu}}
\date{15 June 2022}
\begin{document}
\maketitle
\section{Trigonometry}
\subsection{Exact Values}
\begin{center}
\renewcommand\arraystretch{1.9}
\begin{tabular}{|c|c|c|c|}
\hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% HERE %%%%%%%%%%%%%%%%%%%%%%%
$\theta$ (radians) & \multicolumn{1}{c|}{$\sin\theta$} & \multicolumn{1}{c|}{$\cos\theta$} & $\tan\theta$ \\
\hline
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UP %%%%%%% THERE %%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
$0$ & $0$ & $1$ & $0$ \\%0deg
\hline
$\dfrac{\pi}{12\mathstrut}$ & $\dfrac{\sqrt{2}\left(\sqrt{3}-1\right)\mathstrut}{4}$ & $ $ & $ $ \\%15deg
\hline
$\dfrac{\pi}{10\mathstrut}$ & $ $ & $ $ & $ $ \\%18deg
\hline
$\dfrac{\pi}{6\mathstrut}$ & $ $ & $ $ & $ $ \\%30deg
\hline
$\dfrac{\pi}{5\mathstrut}$ & $ $ & $ $ & $ $ \\%36deg
\hline
$\dfrac{\pi}{4\mathstrut}$ & $ $ & $ $ & $ $ \\%45deg
\hline
$\dfrac{\pi}{3\mathstrut}$ & $ $ & $ $ & $ $ \\%60deg
\hline
$\dfrac{2\pi}{5\mathstrut}$ & $ $ & $ $ & $ $ \\%72deg
\hline
$\dfrac{\pi}{2\mathstrut}$ & $1$ & $0$ & undefined \\%90deg
\hline
\end{tabular}
\label{tab:addlabel}
\end{center}
\end{document}
结果如下所示:ONLY LOOK AT \sin\left(\dfrac{\pi}{12}\right)
我的问题是:
如何增加平方根符号和表格的 \hline 之间的空间?
并保持分数底部与表格底线之间的距离相同。
我是 \LaTeX{} 的新手,所以如果代码看起来不太好,我很抱歉。
答案1
您的代码表明您已经熟悉了\mathstrut
——太棒了!这里有一个建议,可以使其使用更加有效:不要放置\mathstrut
旁边一些项目,就像你在
\dfrac{\pi}{12\mathstrut}
和
\dfrac{\sqrt{2}\left(\sqrt{3}-1\right)\mathstrut}{4}
将其放置在相对于所选项目的下标和上标位置,例如,
\dfrac{\pi}{12_{\mathstrut}}
和
\dfrac{{\sqrt{2}}^{\mathstrut} \,(\sqrt{3}-1)}{4}
请注意,我(a)删除了和\left
大小\right
调整指令,并且(b)将其放置\mathstrut
在相对于分子中最高项目的上标位置,即,\sqrt{2}
。(现在和指令已经消失,放置^{\mathstrut}
在 item 的右侧\sqrt{3}
也可以。但是,如果和仍然存在,看起来会很糟糕。)\left
\right
\left
\right
实施这些建议后,表格的前四行可能如下所示:
请注意,我还用 进行了替换\begin{center} \begin{tabular} ... \end{tabular} \end{center}
,\[ \begin{array} ... \end{array} \]
这样我就可以摆脱大量的$
令牌。
\documentclass[12pt]{article}
%% I've streamlined the preamble as much as possible for this example
\usepackage[hmargin=1.2in,vmargin=1in]{geometry}
\usepackage{array}
\newcolumntype{C}{>{\displaystyle}c<{}}
\begin{document}
\[
\renewcommand\arraystretch{2}
\begin{array}{|C|C|C|C|} % displaystyle math in all columns
\hline
\theta$ (radians)$ & \sin\theta & \cos\theta & \tan\theta \\
\hline
0 & 0 & 1 & 0 \\%0deg
\hline
\frac{\pi}{12_{\mathstrut}}
& \frac{{\sqrt{2}}^{\mathstrut} \,(\sqrt{3}-1)}{4}
& & \\%15deg
\hline
\frac{\pi}{10_{\mathstrut}} & & & \\%18deg
\hline
\end{array}
\]
\end{document}