improved replace_tex_and_web