TMB code for textbooks examples