# Labeling equations in a table

\documentclass{article}
\usepackage{tabularx}
\usepackage{natbib}

\usepackage{verbatim}  % for commenting

\usepackage{float}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{verbatim}  % for commenting

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{siunitx}

\newcommand{\stone}{\theta_1}

\newcommand{\sx}{x}
\newcommand{\sy}{y}

\begin{document}

\begin{table} [tbp]
\centering
\caption{Equations}
\label{table:Equations}
\begin{tabular}{p{0.45in} p{0.5in} p{2.4in}} % {@{}ll@{}}
\toprule
\textbf{Inputs} & \textbf{Output} & \textbf{Equation} \\
\midrule

\rotatebox[origin=c]{0}{$\stone$}
& $\sx$ & $$\tag{1} 0.5 \cos(2\pi\stone) + 0.5$$  \\%\hline

\rotatebox[origin=c]{0}{$\stone$}
& $\sy$ & $$\tag{2} 0.5\sin(2\pi\stone) + 0.5$$\\%\hline

\bottomrule
\end{tabular}
\end{table}

\end{document}


This is how the table looks after the above code is executed:

In this, the columns of the table are not aligned properly. I need the equations to be labeled.

• What's the reason for \rotatebox with a zero angle? Jun 18 at 21:56

Why \rotatebox[origin=c]{0}{$\stone$}?

You can manually step the equation counter.

\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}

% not sure what's the purpose of these commands
\newcommand{\stone}{\theta_1}
\newcommand{\sx}{x}
\newcommand{\sy}{y}

\begin{document}

\begin{table}[htbp]
\centering

\caption{Equations}
\label{table:Equations}

\begin{tabular}{lllr}
\toprule
\textbf{Inputs} & \textbf{Output} & \textbf{Equation} \\
\midrule
$\stone$ & $\sx$ & $0.5 \cos(2\pi\stone) + 0.5$ &
\refstepcounter{equation}\thetag{\theequation}\label{eq:first}
\\
$\stone$ & $\sy$ & $0.5\sin(2\pi\stone) + 0.5$ &
\refstepcounter{equation}\thetag{\theequation}\label{eq:second}
\\
\bottomrule
\end{tabular}

\end{table}

\eqref{eq:first} and \eqref{eq:second}

\end{document}


Whether something like this is better, or something like WinnieNotThePooh's answer might depend on how compact you want the table, but if you want something more compact, you could just manually increase the equation counter:

\documentclass{article}
\usepackage{tabularx}
\usepackage{natbib}

\usepackage{verbatim}  % for commenting

\usepackage{float}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{verbatim}  % for commenting

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{siunitx}

\newcommand{\stone}{\theta_1}

\newcommand{\sx}{x}
\newcommand{\sy}{y}

\begin{document}

\begin{table}[tbp]
\centering
\caption{Equations}
\label{table:Equations}
\begin{tabular}{p{0.45in} p{0.5in} p{2.2in} r@{}} % {@{}ll@{}}
\toprule
\textbf{Inputs} & \textbf{Output} & \textbf{Equation} & \\
\midrule
$\stone$
& $\sx$
& $0.5 \cos(2\pi\stone) + 0.5$
& \refstepcounter{equation}(\theequation)\label{eq:one}
\\
$\stone$
& $\sy$
& $0.5\sin(2\pi\stone) + 0.5$
& \refstepcounter{equation}(\theequation)\label{eq:two}
\\
\bottomrule
\end{tabular}
\end{table}

\end{document}



You should still be able to refer to them with \ref, etc., in the normal way.

With use of the tabularray packages: two possible solutions

\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs, counter, varwidth}

\begin{document}
\begin{tblr}{colspec = {*{2}{Q[l,m, mode=math]}
X[c,m, mode=dmath]
Q[r, cmd=\refstepcounter{equation}]},
row{1} = {font=\bfseries, c, mode=text},
measure = vbox,
}
\toprule
Inputs      &   Output  &   Equation    &           \\
\midrule
\theta_1    &   y   &   %
0.5 \cos(2\pi\theta_1) + 0.5  & \thetag{\theequation}\label{eq:first}   \\
\theta_1    &   y   &   %
0.5 \cos(2\pi\theta_1) + 0.5  & \thetag{\theequation}\label{eq:second}  \\
\bottomrule
\end{tblr}

\medskip
\eqref{eq:first} and \eqref{eq:second}

\vspace{3ex}
\begingroup
\setlength\abovedisplayskip{-1ex}
\setlength\belowdisplayskip{-1ex}
\begin{tblr}{colspec = {*{2}{Q[l,m, mode=math]}
X[c,m]},
row{1} = {font=\bfseries, c, mode=text},
row{2-Y} = {rowsep=-2ex},
measure = vbox,
}
\toprule
Inputs      &   Output  &   Equation        \\
\midrule
\theta_1    &   y   &   $$\label{eq:third} 0.5 \cos(2\pi\theta_1) + 0.5$$      \\
\theta_1    &   y   &   $$\label{eq:fourth} 0.5 \cos(2\pi\theta_1) + 0.5$$      \\
\theta_1    &   y   &   $$\label{eq:fifth} 0.5 \cos(2\pi\theta_1) + 0.5$$      \\
\bottomrule
\end{tblr}
\endgroup

\medskip
\eqref{eq:third}, \eqref{eq:fourth}  and \eqref{eq:fifth}
\end{document}


You cannot use $$...$$ inside a table cell. If you want it to look like a displayed equation, you can do this:

... & $$\displaystyle 0.5 \cos(2\pi\stone) + 0.5$$


But You can try something like that:

\documentclass{article}
\usepackage{tabularx}
\usepackage{natbib}

\usepackage{verbatim}  % for commenting

\usepackage{float}
\usepackage{array}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage{verbatim}  % for commenting

\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{amsmath}
\usepackage{siunitx}

\newcommand{\stone}{\theta_1}

\newcommand{\sx}{x}
\newcommand{\sy}{y}

\begin{document}

\begin{table} [tbp]
\centering
\caption{Equations}
\label{table:Equations}
\begin{tabular}{p{0.45in} p{0.5in} p{2.4in}} % {@{}ll@{}}
\toprule
\textbf{Inputs} & \textbf{Output} & \textbf{Equation} \\
\midrule

\rotatebox[origin=c]{0}{$\stone$}
& $\sx$ &  \parbox{4cm}{$$0.5 \cos(2\pi\stone) + 0.5$$} \\%\hline

\rotatebox[origin=c]{0}{$\stone$}
& $\sy$ &  \parbox{4cm}{$$0.5\sin(2\pi\stone) + 0.5$$}\\%\hline

\bottomrule
\end{tabular}
\end{table}

\end{document}


So, as You understand enumerate equations in table isn't nice idea but I would recomend You to look at this answer and make something like that)