I want to decide if some label occurs in the same chapter as the current one. I use the zref package as suggested in Chapter ref with LaTeX to find out in which chapter a label occurs, and compare this to the current one. I tried to do this with both the counter's display and value.
Here is what I do:
\documentclass{scrbook}
\usepackage[user]{zref}
\makeatletter
\zref@newprop{chapter}{\thechapter}
\zref@newprop{chaptervalue}{\the\value{chapter}}
\zref@addprops{main}{chapter,chaptervalue}
\makeatother
\begin{document}
\chapter{Chapter 1}
\zlabel{chapone}
Compare \thechapter{} with \zref[chapter]{chapone}. Equal:
\ifstr{\thechapter}{\zref[chapter]{chapone}}{Yes.}{No.}
Compare \thechapter{} with \zref[chapter]{chaptwo}. Equal:
\ifstr{\thechapter}{\zref[chapter]{chaptwo}}{Yes.}{No.}
Compare \the\value{chapter} with \zref[chaptervalue]{chapone}. Equal:
\ifstr{\thechapter}{\zref[chapter]{chapone}}{Yes.}{No.}
Compare \the\value{chapter} with \zref[chaptervalue]{chaptwo}. Equal:
\ifstr{\thechapter}{\zref[chapter]{chaptwo}}{Yes.}{No.}
\chapter{Chapter 2}
\zlabel{chaptwo}
\end{document}
In any case, the result is "No.", even if the values are equal.
I was using \ifstr from the KOMA-Skript package to compare the strings (as I am using this documentclass anyway), but this also happens when one uses other string comparison functions (I have tried \ifthenelse{\equal{<str1>}{<str2>}}{<true>}{<false>} from the ifthen package and \IfStrEq from the xstring package).
Does anyone understand why this happens? Or can you imagine another way to compare these values?
