Is there a way for including assertions in a LaTeX document? I want to check that some condition is true, and only allow compilation of the document if it is (or at least complain otherwise).
Specifically, a paragraph contains a reference to a chapter. Before compiling the final version, I'd like to be warned if the chapter is the current chapter, so that I could e.g. substitute the text with "in this chapter".