When editting a notebook I tend to rerun the cells many times. But imports are only done once, so the code in book_format() is only run the first time. I put all of that code in a function so that it is run every time.