-2

I have a Tex file. Which I want to convert to txt file using C#. Please help. I am sure the info it contains is plain text but format used is Tex.

Rajdip
  • 33
  • 8

1 Answers1

0

TeX files need to be fully interpreted before any sort of text can be reliably extracted. Writing a full-fledged TeX interpreter in C# may be a real task, so instead I would suggest using an existing interpreter that can output a format that can be parsed more easily, such as HTML.

You may feel inclined to write a regular expression to simply strip all \command, but this won't give you a very accurate result, because some commands produce text of their own, and [less commonly] some commands gobble the text that follows it. Also, you will run into issues where characters change category codes, some characters may be in the active category code, meaning characters on their own can be commands.

dreamlax
  • 93,976
  • 29
  • 161
  • 209