2

The code is:

\begin{equation*}
\[I(t)=\begin{cases}
1; & |t|\le\frac{{\Delta}t_{p}^{FWHM}}{2}\\
0; & |t|>\frac{{\Delta}t_{p}^{FWHM}}{2}
\end{cases}\]
 \end{equation*}\\

the error is missing $ inserted and bad math delimiter, what should I do for this?

I try to generate a table, the above codes are some equation in the table, the whole codes are attached below:

\begin{table}[!htb]
\begin{center}
\renewcommand{\arraystretch}{2.7}
\begin{tabular}{|c|c|}
\hline
\multicolumn{2}{|c|}{Square Pulse} \\
\hline
Pulse & 
\begin{equation*}
\[I(t)=\begin{cases}
1; & |t|\le\frac{{\Delta}t_{p}^{FWHM}}{2}\\
0; & |t|>\frac{{\Delta}t_{p}^{FWHM}}{2}
\end{cases}\]
 \end{equation*}\\
 \hline
Autocorrelation & 
\begin{equation*}
    \[A^{(2)}(\tau)=\begin{cases}1-|\frac{\tau}{\Delta\tau_{A}^{FWHM}}|; &|\tau|\le\Delta\tau_{A}^{FWHM}\\
0; &|\tau|>\Delta\tau_{A}^{FWHM}\end{cases}\]
\end{equation*} \\
 \hline
 Relationship & ${\Delta}t_{p}^{FWHM}=\Delta\tau_{A}^{FWHM}$ \\
 \hline
 \multicolumn{2}{|c|}{Gaussian Pulse} \\
 \hline
 Pulse & $I(t)=exp[-(2\sqrt{ln2t}/{\Delta}t_{p}^{FWHM})^2]$ \\ 
 \hline
 Autocorrelation & $A^{(2)}(\tau)=exp[-         (2\sqrt{ln2\tau}}/{\Delta\tau_{A}^{FWHM}})^2)^2$ \\
 \hline
 Relationship & $1.41{\Delta}t_{p}^{FWHM}=\Delta\tau_{A}^{FWHM}$ \\
 \hline
 \end{tabular}
\centering{
\caption{The relationship between the initial pulse and autocorrelation of square pulse and Gaussian pulse}
\label{table AC1}}
\end{center}
\end{table}
  • 5
    \begin{equation*} is similar to \[ and not allowed. Use either \begin{equation*}...\end{equation*} or \[...\]. – Werner Sep 8 '16 at 17:28
  • 3
    Possible duplicate: “!Missing $ inserted” error using amsmath environments – Werner Sep 8 '16 at 17:35
  • Yes, you are right, I removed [ and it seems better, but still warning missing $ inserted, I still have no idea how to deal with it. – MINGYANG ZHANG Sep 8 '16 at 17:58
  • 1
    please provide a document (not just a fragment) that demonstrates the error, then it is much easier for people to fix. – David Carlisle Sep 8 '16 at 18:01
  • 1
    Yes, it's a good point that I need to provide the whole environment, otherwise it's difficult to find the problem. And I find out where the error comes from, it's just I cannot use \begin{equation}...\end{equation} in the table cell, when I try to use $...$ or (...), the warning is gone. BTW, I have to say that this is part of my degree thesis, it's quite long and not easy to put the whole document on this page. Thanks very much Werner and David, really helps a lot and give me some useful idea to deal with this problem. – MINGYANG ZHANG Sep 8 '16 at 18:11
7

You shouldn't be using either \begin{equation*} ... \end{equation*} or \[ ... \] inside the columns of a tabular environment. Instead, simply change the column definition of the right-hand column from c to >{$\displaystyle}c<{$}; this will ensure that all cells in the second column will automatically be in math mode.

You have several (syntax) errors in the equations. Also, write \exp and \ln instead of just exp and ln; that way, "exp" and "ln" will be typeset using upright letters.

Also, where possible, avoid using fractional expressions using \frac in the second column; instead, using "inline-style" fractions, e.g., a/b instead of \frac{a}{b}.

enter image description here

\documentclass{article}
\usepackage{mathtools,array}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}
\newcommand\FWHM{\mathrm{FWHM}}
\begin{document}
\begin{table}[!htb]
\centering
\renewcommand{\arraystretch}{2.75}
\begin{tabular}{|l|>{$\displaystyle}l<{$}|}
\hline
\multicolumn{2}{|c|}{Square Pulse} \\
\hline
Pulse & 
I(t)=
\begin{cases}
1; & \abs{t}\le\tfrac{1}{2}\Delta t_{p}^{\FWHM}\\[1.5ex]
0; & \abs{t}>  \tfrac{1}{2}\Delta t_{p}^{\FWHM}
\end{cases}
 \\
\hline
Autocorrelation & 
A^{(2)}(\tau)=
\begin{cases}
1-\abs*{\tau\big/\Delta\tau_{A}^{\FWHM}}; 
& \abs{\tau}\le\Delta\tau_{A}^{\FWHM}\\[2ex]
0;  & \abs{\tau}>\Delta\tau_{A}^{\FWHM}
\end{cases}
 \\
\hline
Relationship & {\Delta}t_{p}^{\FWHM}=\Delta\tau_{A}^{\FWHM} \\
\hline
 \multicolumn{2}{|c|}{Gaussian Pulse} \\
 \hline
 Pulse & I(t)=\exp\Bigl[-\bigl(2\sqrt{\ln2t}/{\Delta}t_{p}^{\FWHM}\bigr)^2\Bigr] \\ 
\hline
Autocorrelation & 
A^{(2)}(\tau)=\exp\Bigl[-\bigl(2\sqrt{\ln2\tau}/\Delta\tau_{A}^{\FWHM}\bigr)^2\Bigr] \\
\hline
Relationship & 
{\Delta}t_{p}^{\FWHM}=\Delta\tau_{A}^{\FWHM} \\
\hline
 \end{tabular}
\caption{The relationship between the initial pulse and autocorrelation of square pulse and Gaussian pulse}
\label{table AC1}
\end{table}

\end{document}

Addendum: Your table contains lots of vertical and horizontal lines, which actually don't enhance the readability of its contents. You may want to give some thought to giving the table a more "open" look, e.g., by getting rid all vertical lines and most horizontal lines. I hope you will agree that the following table is much more "inviting" to the readers' eye (and brain...).

enter image description here

\documentclass{article}
\usepackage{mathtools,array,booktabs}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}  % "absolute value" macro
\newcommand\FWHM{\mathrm{FWHM}}
\begin{document}
\begin{table}[!htb]
\centering
\renewcommand{\arraystretch}{1.25}
\begin{tabular}{@{}l>{$\displaystyle}l<{$}@{}}
\toprule
\multicolumn{2}{@{}l}{\bfseries Square Pulse} \\
\addlinespace
Pulse & 
I(t)=
\begin{cases}
1; & \abs{t}\le\tfrac{1}{2}\Delta t_{p}^{\FWHM}\\[1ex]
0; & \abs{t}>  \tfrac{1}{2}\Delta t_{p}^{\FWHM}
\end{cases}
 \\
\addlinespace
Autocorrelation & 
A^{(2)}(\tau)=
\begin{cases}
1-\abs*{\tau\big/\Delta\tau_{A}^{\FWHM}}; 
& \abs{\tau}\le\Delta\tau_{A}^{\FWHM}\\[1ex]
0;  & \abs{\tau}>\Delta\tau_{A}^{\FWHM}
\end{cases}
 \\
\addlinespace
Relationship & {\Delta}t_{p}^{\FWHM}=\Delta\tau_{A}^{\FWHM} \\
\midrule
\multicolumn{2}{@{}l}{\bfseries Gaussian Pulse} \\
\addlinespace
Pulse & I(t)=\exp\bigl[-\bigl(2\sqrt{\ln2t}\big/{\Delta}t_{p}^{\FWHM}\bigr)^2\,\bigr] \\ 
\addlinespace
Autocorrelation & 
A^{(2)}(\tau)=\exp\bigl[-\bigl(2\sqrt{\ln2\tau}\big/\Delta\tau_{A}^{\FWHM}\bigr)^2\,\bigr] \\
\addlinespace
Relationship & 
{\Delta}t_{p}^{\FWHM}=\Delta\tau_{A}^{\FWHM} \\
\bottomrule
 \end{tabular}
\caption{Relationship between initial pulse and autocorrelation for square and Gaussian pulses}
\label{table AC1}
\end{table}

\end{document}
  • Wow, you are really a genius. Really useful for my thesis, thank you very much. I will change all the codes as you commanded. – MINGYANG ZHANG Sep 11 '16 at 12:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.