如何标记并引用表格中的特定行?

如何标记并引用表格中的特定行?

我正在创建一个表来记录一些计算邻近运算符的规则。我希望能够标记某些行并在以后引用它们。有什么好方法可以做到这一点?

这是我目前拥有的表格的 MWE:

\documentclass{article}
\usepackage{amsmath,amssymb,algpseudocode,algorithm,booktabs}
\newcommand{\prox}{\text{prox}}

\begin{document}

\begin{table}[htbp]
\renewcommand{\arraystretch}{1.3}
\begin{center}
\caption{Prox-operator calculus rules}
\label{proxRulesTable}
\begin{tabular}{@{}l l l  @{}}
\toprule
$g(x)$ & $\prox_{tg}(x)$ \\ \midrule
$\sum_{k=1}^K f_k(x_k)$ & $(\prox_{tf_1}(x_1),\ldots,\prox_{t f_K}(x_K))$ \\
$cf(x - x_0)$ & $\prox_{ctf}(x - x_0) + x_0$ \\
$f^*(x)$ & $x - t \prox_{(1/t)f}(x/t)$ \\
$I_C(x)$ & $P_C(x) = \text{projection of } x \text{ onto } C$ \\
$I_{\geq 0}(x)$ & $x_+ = \max(x,0)$ \\
$\| x \|$ & $x - t P_B(x)$, where $B$ is dual norm unit ball \\
\end{tabular}
\end{center}
\end{table}

\end{document}

这是我目前拥有的表格的图片:

未标记的表

答案1

不太清楚您想要什么样的标签或如何引用它们。也许是这样的?

\documentclass{article}
\usepackage{amsmath,amssymb,algpseudocode,algorithm,booktabs}
\newcommand{\prox}{\text{prox}}
\newcounter{proxy}[table]
\setcounter{proxy}{0}
\renewcommand*\theproxy{\thetable.\arabic{proxy}}
\newcommand*\makeproxy[1]{\refstepcounter{proxy}(\theproxy)\label{#1}}
\begin{document}

\begin{table}[htbp]
  \renewcommand{\arraystretch}{1.3}
  \centering
  \caption{Prox-operator calculus rules}
  \label{proxRulesTable}
  \begin{tabular}{@{}l l l  @{}}
    \toprule
    $g(x)$ & $\prox_{tg}(x)$ \\ \midrule
    $\sum_{k=1}^K f_k(x_k)$ & $(\prox_{tf_1}(x_1),\ldots,\prox_{t f_K}(x_K))$ \\
    $cf(x - x_0)$ & $\prox_{ctf}(x - x_0) + x_0$ & \makeproxy{row:a}\\
    $f^*(x)$ & $x - t \prox_{(1/t)f}(x/t)$ \\
    $I_C(x)$ & $P_C(x) = \text{projection of } x \text{ onto } C$ \\
    $I_{\geq 0}(x)$ & $x_+ = \max(x,0)$  & \makeproxy{row:b}\\
    $\| x \|$ & $x - t P_B(x)$, where $B$ is dual norm unit ball \\
  \end{tabular}
\end{table}

As shown in rows \ref{row:a}, \ref{row:b}, \ref{row:c}, \ref{row:d} and \ref{row:e}\dots

\begin{table}[htbp]
  \renewcommand{\arraystretch}{1.3}
  \centering
  \caption{Prox-operator calculus rules}
  \label{proxRulesTable2}
  \begin{tabular}{@{}l l l  @{}}
    \toprule
    $g(x)$ & $\prox_{tg}(x)$ & \makeproxy{row:c} \\ \midrule
    $\sum_{k=1}^K f_k(x_k)$ & $(\prox_{tf_1}(x_1),\ldots,\prox_{t f_K}(x_K))$ \\
    $cf(x - x_0)$ & $\prox_{ctf}(x - x_0) + x_0$ & \makeproxy{row:d} \\
    $f^*(x)$ & $x - t \prox_{(1/t)f}(x/t)$ \\
    $I_C(x)$ & $P_C(x) = \text{projection of } x \text{ onto } C$ \\
    $I_{\geq 0}(x)$ & $x_+ = \max(x,0)$ & \makeproxy{row:e} \\
    $\| x \|$ & $x - t P_B(x)$, where $B$ is dual norm unit ball \\
  \end{tabular}
\end{table}

\end{document}

表格参考

相关内容