3

Got a problem with the square root sign inside a table: SEE THE COMMENTED PART

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

The result looks something like this: ONLY LOOK AT \sin\left(\dfrac{\pi}{12}\right) ONLY LOOK AT \sin\left(\dfrac{\pi}{12}\right)

MY QUESTION IS:

How can I increase the space between the square root symbol and the \hline of the table?

And keeping the distance between the bottom of the fraction and the bottom line of the table the same.

I am new to \LaTeX{}, so sorry if the code isn't looking too good.

3

1 Answer 1

4

Your code shows that you're already familiar with \mathstrut -- great! Here's a suggestion for making its use even more effective: Instead of placing \mathstrut next to some item, as you do in

\dfrac{\pi}{12\mathstrut}

and

\dfrac{\sqrt{2}\left(\sqrt{3}-1\right)\mathstrut}{4}

place it in sub- and superscript positions relative to the chosen item, e.g.,

    \dfrac{\pi}{12_{\mathstrut}}

and

\dfrac{{\sqrt{2}}^{\mathstrut} \,(\sqrt{3}-1)}{4}

Note that I (a) got rid of the \left and \right sizing directives and (b) placed \mathstrut in superscript position relative to the tallest item in the numerator, viz., \sqrt{2}. (Placing ^{\mathstrut} to the right of \sqrt{3} item would work as well, now that the \left and \right directives are gone. It would look bad, though, if \left and \right were still there.)

After implementing these suggesetions, the first four rows of the table might look like this:

enter image description here

Note that I've also replaced \begin{center} \begin{tabular} ... \end{tabular} \end{center} with \[ \begin{array} ... \end{array} \], letting me get rid of lots and lots of $ tokens.

\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}
1
  • Thank you so much! Jun 19, 2022 at 3:44

You must log in to answer this question.

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