# Relative reference in TeX (exercise 1 of this chapter)

In a standard textbook, there is several chapters and each chapter has several exercises, if you are writing in LaTeX or texinfo, how are these exercises referenced in body text?

What I see always depends on giving a unique name to each exercise:

like this texinfo format of SICP: https://raw.githubusercontent.com/sarabander/sicp/master/sicp-pocket.texi

Each exercise has a numbered name, like 1.1.1 but it will be a lot of trouble if you want to for example add a new chapter between chapter 2 and 3...

or like this for the Stacks project:

https://github.com/stacks/stacks-project/blob/master/exercises.tex

each exercise is given a globally unique name.

Consider how binding is done in programming languages, we can image a document format that handles bindings more elegantly. This will enable more "refactoring" of the document

chapter(title = "Basic things you need to know", body = "
Body text, body text

@exercises(0)
", exercises = [
])


So my question is, due to my limited knowledge of LaTeX and other tools, is relative referencing possible in any tool you knows? Like LaTeX? MS Word?

• @HeikoOberdiek hello! Do you have any insight to my question? – molikto Apr 16 '17 at 7:01
• use label and ref. The first one inserts an anchor which you name e.g. \label{exercise} the second one reference to the correct representation of that counter e.g. \ref{exercise} will printout the correct exercise number automatically, given that you run LaTeX at least twice. – Moriambar Apr 16 '17 at 7:32
• The labelling system is just meant for doing this, with unique names specified by hand (don't use numbers in labels that are connected to the labelled entity, i.e. the section). Possibly my answer here is of use to you – user31729 Apr 16 '17 at 7:35
• @Moriambar What I means is is their any scope/binding/shadowing mechanism in LaTeX? tex.stackexchange.com/questions/181434/… also "subobject" references like exercises(0)? If you never delete a exercise... it is ok to use numbers to reference it, it might be convenient in some cases – molikto Apr 16 '17 at 10:52
• @ChristianHupfer See my previous comment :-) – molikto Apr 16 '17 at 10:53