fix function definitions

Now, functions defined in one block of Python code embedded in LaTeX
also work in every other block.