[Tex/LaTex] Creating a new environment with referencing


I'm trying to create a referenceable "system" environment that basically displays an equation with a custom counter. Then I want to reference the environment with autoref, so as to have "System (S1)" as output when I reference it.




 \dot x=u(x),

However, when I do


I get an error saying that the reference s1 is undefined. What am I missing?

Best Answer

Some remarks:

  • The label has used the name s1, the references system. The label name must match, the example below uses s1.
  • The use equation* indicates that probably package amsmath is used.
  • With amsmath \tag can be used to print the equation number.
  • Redefining \p@system helps to get the parentheses around the number, when it is referenced.
  • I have put \label outside environment equation with the name as option to the environment system to avoid trouble with the redefinition of \label inside environments of amsmath.
  • The star form of \ref avoids the link inside a link in the line with \hyperref.






\hyperref[s1]{System~\ref*{s1}}, \autoref{s1}

 \dot x=u(x),

Related Question