I'm in the process of converting latex to xml. So, I need to convert latex entities into hex value. I thought to convert from latex entities to html to hex entities or can it be done directly from latex to hex value? Is there any way to do this?

For example: \& to & , {\'o} to ó

I need to convert only symbols and specials characters.

  • 1
    What exactly do you mean? Like converting LaTeX control sequences to hex values? Or lengths? – Stefan Kottwitz Feb 11 '15 at 14:25
  • I assume you mean the subset of latex commands that can be considered as names of single Unicode characters, and you want the Unicode code points, as hex? – David Carlisle Feb 11 '15 at 14:26

Any existing tex-to-html or tex-to-xml convertor will be doing this already but if you are rolling your own code the easiest place to get the table of replacements that you need is in the file used by the utf8 inputenc option, which is doing the same job.

utf8enc.dfu will be in your distribution in the same directory as article.cls, latex.ltx and the rest of the base latex files.

It has lots of the lines like


which tells you that \"e (and \"{e}) need to be translated to U+00eb or a numeric reference to that such as ë so you just need to transform the above into a regular expression replace such as


and apply it to your document.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.