\theoremstyle{plain}
\newtheorem{Condition}{Condition}
Say I call it like this:
\begin{Condtion}[Symmetry]
\label{cnd:sym}
foo foo foo
\end{Condition}
Now I want to be able to call some variant of the \ref command, and
have the NAME of the environment (eg "Symmetry").
\ref calls the number [which is not displayed anywhere else]
\thref writes "Condition n" for the nth condition
\nameref writes the name of the SECTION of the label.
zref seems like an awfully complex way of doing something pretty darn
simple. Any answers?
zref is not "complex", but requires initialization (definition of
properties).
To force \nameref to come with the "correct" name, you have to
update \@currentlabelname at the beginning of your environment:
set
\def\@currentlabelname{Symmetry} for example
before \label.
Regards.
I could do that, but then I might as well just do \newcommand{\refsym}
{\textbf{Symmetry}} and use that instead of referencing. The point is
that I want to try and call the optional argument of the environment...
I know, just embed your environment :
\newtheorem{CONDITION}{Condition}
\newenvironment{Condition}[1][]{%
\begin{CONDITION}%
\def\@currentlabelname{#1}%
}{%
\end{CONDITION}%
}
%%%
\begin{Condition}[Symmetry]
\label{cnd:sym}
foo foo foo
\end{Condition}
Not tested, but I think it should work...
That breaks the naming. The condition itself then becomes named
"Condition 1". But i see what you are trying to do...
> I'm using ntheorem package and I have a custom environment that is set
> up as follows:
>
> \theoremstyle{plain}
> \newtheorem{Condition}{Condition}
>
> Say I call it like this:
>
> \begin{Condtion}[Symmetry]
> \label{cnd:sym}
> foo foo foo
> \end{Condition}
>
> Now I want to be able to call some variant of the \ref command, and
> have the NAME of the environment (eg "Symmetry").
This appears to work and is likely to show up in the next release of
thmtools:
\documentclass{article}
\usepackage{ntheorem,thmtools,nameref,hyperref}
\newtheorem{Condition}{Condition}
\makeatletter
\addtotheorempostheadhook[Condition]{%
\ifcsname NR@gettitle\endcsname% guard in case it's not defined
\expandafter\NR@gettitle\expandafter{\thmt@optarg}%
\fi
}
\makeatother
\begin{document}
\begin{Condition}[Symmetry]
\label{cnd:sym}
foo foo foo
\end{Condition}
See \autoref{cnd:sym} `\nameref{cnd:sym}' on \autopageref{cnd:sym}.
\end{document}
HTH
Ulrich