1

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?

molikto
  • 111
  • @HeikoOberdiek hello! Do you have any insight to my question? – molikto Apr 16 '17 at 07: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 07: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 –  Apr 16 '17 at 07:35
  • @Moriambar What I means is is their any scope/binding/shadowing mechanism in LaTeX? https://tex.stackexchange.com/questions/181434/what-does-label-multiply-defined-mean 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
  • @molikto: That post does not rely clearify what you're after. I think you have a misunderstanding of the label/reference system –  Apr 16 '17 at 10:55
  • @ChristianHupfer Yes I know... that post means that it is preferred to always give labels globally unique names, What I ask is that if the "name resolution" can be done more complex, like what we have in a programming language, their is "name shadowing" there is "names.names" and etc.. – molikto Apr 16 '17 at 11:04
  • @molikto: I was thinking of a namespace facility for labels recently, but there's a package in the meantime by Takuto Asakura: wtref –  Apr 16 '17 at 11:14

0 Answers0