Retrieving the title of a theorem, e.g. "My name" from "Lemma 1 (My name)"

The thmtools package allows to do that easily:

\documentclass{article}
\usepackage{hyperref}
\usepackage{thmtools}
\declaretheorem{Theorem}
\begin{document}

\begin{Theorem}[My Theorem]\label{thm}
  $1 + 3 = 4$
\end{Theorem}

As we saw in Theorem~\ref{thm} (\nameref{thm})

\end{document}

Referring to the Theorem by its name

You can obtain the same using amsthm:

\documentclass{article}
\usepackage{hyperref}
\usepackage{amsthm}
\newtheorem{thm}{Theorem}
\begin{document}

\begin{thm}[My Theorem]\label{thm}
  $1 + 3 = 4$
\end{thm}

As we saw in Theorem~\ref{thm} (\nameref{thm})

\end{document}

Finally, if you want to have a signle link instead of two, you can use the following:

\documentclass{article}
\usepackage{hyperref}
\usepackage{thmtools}
\declaretheorem{Theorem}

\begin{document}

\begin{Theorem}[My Theorem]\label{thm}
  $1 + 3 = 4$
\end{Theorem}

As we saw in \hyperref[thm]{Theorem~\ref*{thm} (\nameref*{thm})}.

\end{document}

The same, with a single link.

And if you don't want any link, just use \nameref*{thm}.

I guess you'll be able to adapt the code to print "Law" instead of "Theorem".


Here is an additional solution that uses amsthm and is indipendent from hyperref. It mimics LaTeXs built in cross-ref-routine:

\documentclass{article}
\usepackage{amsthm}
\usepackage{amssymb}

\newtheorem{law}{Law}

\makeatletter
\let\sv@law\law
\let\sv@label\label
\renewcommand\law[1][]{\sv@law[#1]\def\curr@thmname{#1}}
\renewcommand\label[1]{%
  \immediate\write\@auxout{%
    \noexpand\global\noexpand\@namedef{#1-thmname}{\curr@thmname}}
  \sv@label{#1}
}
\newcommand\nameofthm[1]{\@nameuse{#1-thmname}}
\makeatother

\begin{document}
%Law~\ref{RTA_Ref}~(\nameofthm{RTA_Ref}) 
%
\begin{law}[Rely-to-Atomic]\label{RTA_Ref}
For any predicate $p$, and relations $r$ and $q$, such that $[p,q]$ tolerates interference $r$,
\[
  \mathbf{rely}\,r\cdot[p,q]\sqsubseteq\langle p,q\rangle
\]
\end{law}

...

Law~\ref{RTA_Ref}~(\nameofthm{RTA_Ref})
\end{document}

example_rendered