adapt abstract code to unescape latex stuff. probably a fragile implementation