I would like to label the hypotheses in my thesis similar to equations (e.g., the first hypothesis in chapter 3 should be “H-3.1”). Also similar to equations, I would like to reference these hypotheses. What I got so far is the following (which is based on this answer):
\documentclass{book}
\newcounter{hypCNT}
\newcommand{\hypCnt}[2]{\refstepcounter{hypCNT}\label{#1}H-\arabic{chapter}.\arabic{hypCNT}}
\begin{document}
\chapter{Lorem}
Hypotheses: \\
Pigs can fly (\hypCnt{hyp:H1}) \\
The world is a disk (\hypCnt{hyp:H2})\\
Hypotheses \ref{hyp:H1} on page \pageref{hyp:H1}
\end{document}
Which leads to:
Chapter 1
Lorem
Hypotheses:
Pigs can fly (H-1.1
The world is a disk (H-1.2
Hypotheses 1 on page 1
This solution is close but not exactly what I would like to have. Actually I would like the H-\arabic{chapter} to be part of the label. Of course I could define another \newcommand{\refHyp} also containing the H-\arabic{chapter} part. However, if I would reference a H-label out of another chapter I would get the chapter number of the current chapter and not the one I am actually referencing to.
Another strange thing: Why does the closing bracket disappear behind the \hypCnt{}?
Any ideas appreciated a lot!
fancyreforcleverref? – cfr Apr 08 '15 at 23:45)is swallowed and digested by the fact that\hypcnthas two arguments but you call it with just one! – Apr 08 '15 at 23:46\hypCntto take 2 arguments yet you only supply one (explicitly). As such, TeX grabs whatever token follows your use of\hypCnt{.}, which is)in this case. – Werner Apr 08 '15 at 23:46\hypCntwith one argument only. Now, one argument is perfectly fine. @cfr: Thanks for the hint. I am going to check these. – ToJo Apr 08 '15 at 23:57