In my project, i am converting .docx file (containing OMML) into XML & now i am trying to convert this XML file into LaTex document format. Is it possible to convert XML file into LaTex file using java ?
Asked
Active
Viewed 669 times
-1
-
hmmm I found Latex to be hard to write by itself, now converting from xml to latex, good luck with that. :)). joke aside, from my knowledge there is no library to do it automatically, you need to build your own library. – nafas Mar 31 '15 at 15:03
-
Thanks nafas, any guidelines are most welcome ? – FullStack Mar 31 '15 at 15:05
-
What does your XML schema look like? Is it DocBook? – Puce Mar 31 '15 at 15:08
-
Hello Puce,thanks for concern, my XML is a normal XML document containing simple text & mathematical formula. – FullStack Mar 31 '15 at 15:14
-
@MaximusDecimusMeridius could you show an example what sort of mathematical formulas are they?, for example is "alpha" written as "alpha" or "α"? – nafas Mar 31 '15 at 15:21
-
@nafas you picked right, alpha is written as α in my xml document, same is the case with other symbols,they are mentioned as is. – FullStack Mar 31 '15 at 15:26
-
1There is no such thing like “a normal XML document”. In fact, your original `.docx` file was a container already holding XML files. But well, the answer to your question is *yes*. – Holger Mar 31 '15 at 17:07
-
I'd strongly suggest using [John McFarlane's excellent pandoc application](https://github.com/jgm/pandoc) for this instead of reinventing the wheel. It would allow direct DocX->LaTeX conversion by a simple call of an external program. – Markus W Mahlberg Mar 31 '15 at 17:29
-
Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer! Also see [how to ask](http://stackoverflow.com/help/how-to-ask) – Scott Solmer Mar 31 '15 at 17:57
1 Answers
0
Ok mate, I'm giving you some advice here by no means its a complete solution.
Assuming There is no library already implemented.
If it was me trying to implement a simple XML to LaTeX conversion. I would start with a simple map of all those mathematical characters(or atleast find a good source that has them)
for example something like this:
α <--> $\alpha$ //note \alpha is symbol of α in latex but it has to be in math mode
γ <---> $\gamma$
then you can replace them all.
for layout indention you could do something using this:
root node <--> no indent
1st child <--> \parindent{10pt}
2st child <--> \parindent{20pt}
and so on
well I'm using Latex for 5 years now, and still struggling. but it would be great if there was such thing (xml to latex) convertor.

nafas
- 5,283
- 3
- 29
- 57