10

I've started using LaTeX a few weeks ago and I really like it.

Now... I have a bunch of MS Word templates (.dotx files) I'd like to convert to LaTeX. Each of these templates basically consists of fonts, header, footer, several paragraph styles, etc.

Is there any tool or procedure I can follow to automate this Word to LaTeX template conversion?

mauro
  • 201
  • 14
    Short answer: No. – Johannes_B Jan 13 '16 at 18:31
  • I don't want to convert LaTeX into Open Office/MS Word. I want to convert the other way around. And... I want to convert templates! – mauro Jan 13 '16 at 18:32
  • 1
    The answer is as Johannes has already written. :-) – Svend Tveskæg Jan 13 '16 at 18:34
  • If you are beginning with LaTeX just forget about paragraph styles and so on… I know it is hard for people used to WYSIWYG but the proper way to learn LaTeX is to stick with its nice default styles. When you will master it, it will be time to make your custom styles. LaTeX philosophy is that the beginner should not worry about form and concentrate on what he intends to demonstrate. If you really want to have a fine control on your styles, I would suggest you to learn ConTeXt. – sztruks Jan 13 '16 at 18:37
  • Ok thanks. I did read about a tool named writer2latex but maybe I was wrong... Thanks again – mauro Jan 13 '16 at 18:41
  • 4
    These tools are for converting content (and don’t work that well). As far as I know there’s no automatic way to convert layouts/settings. That must be done manually … but there are experts out there (including me) who can do this work for you ;-) – Tobi Jan 13 '16 at 19:08
  • 3
    The .docx to .tex conversion have sense to save contents at the price of obtain dirty code (sometimes very hard to clean). For templates is just better star with a empty file or an existing LaTeX template. Using the blindtext package and playing with some others as geometry and fancyhdr you can obtain a nice template in minutes and check how it look with text. – Fran Jan 13 '16 at 20:16
  • 2
    @sztruks I think your advice is a bit too drastic. While there is something to be said for sticking with basic styles, the fact that mauro has templates in Word with styles already shows that he understands the difference between formatting and content, as that what Word styles are. The average Word user doesn't use styles, which then makes the adaptation to LaTeX difficult. But learning how to make headers and footers and format lists or other sections is quite basic LaTeX use. Converting Word styles (not documents) to LaTeX isn't so hard for a beginner if you understand the concepts. – Alan Munn Jan 13 '16 at 23:35
  • Thank you all for your inputs (a special thank to Fran and Alan Munn - their tips put me on the right track). It took almost 90 minutes to manually convert the first template but I was continuously switching back and forth between documentation and the real conversion activity. I'm pretty sure the other ones will take just a few minutes. Next step... I will have to automatically fill part of these templates with the output of certain commands (but this is the easy part for me). Thanks again... great support ;-) – mauro Jan 14 '16 at 04:37
  • 3
    @mauro -- since you've been successful, when you have a few minutes, it would be helpful to future readers if you could write a self-answer with a few pointers to what steps you actually took to convert your templates. it's nice to hear about a success story. – barbara beeton Jan 15 '16 at 21:35
  • @barbara beeton. Yes I was going to answer myself with the steps I did follow. I' pretty sure you experts will have a lot to comment :-)... but, at the end, I'm happy: (first) if you look at the final PDF it's almost impossible to distinguish it from the one generated using MS Word, (second) I can now automatically generate 70% of the documents using Perl/bash scripts under *nix – mauro Jan 16 '16 at 03:25
  • @mauro follow up on this..? :P – Georges Aug 09 '18 at 08:05

3 Answers3

5

The answers have been given in the comments, but maybe somebody later finds this question and there is a bit more to say than above.

There is no converter software for Word templates (*.dot or .dotx). Of course there is a bunch of solutions how to convert a Word file (.doc or *.docx) to LaTeX code; if you need that, search for word2tex. LibreOffice has an export to LaTeX function, which might be used as well.

The question is about templates, namely *.dotx files.

*.dot(x) files can contain macros, pictures, a complete layout of a flyer, whatever. For each element you have to search for the equivalent package, options and commands in the LaTeX world.

For example take an invoice with carry over from the first to the second page, sent by letter. More or less easy with Word, more difficult with LaTeX.

You'd have to construct the head / layout of the letter, e.g. using the scrletter package.

But the tabular with the carry over were a real problem, if there weren't this wonderfull solution: https://tex.stackexchange.com/a/157193/4736

This might explain why it is close to impossible to write a converter. Maybe in 25 years? No, I don't think that people will use Word then...

Keks Dose
  • 30,892
5

This answer addresses a specific subset of the cases which the question might apply to.

In some cases. .dot(x) files are relatively simple but, as pointed out by others, they can be more complex. Moreover, the last time I attempted to deal with such things, they were typically created on the basis of a document. Essentially, you created a document with the stuff you needed and then saved it as a template. You could edit them etc., but that was also quite like editing a document.

So, although you can't directly convert a template, you can use it to create a document and then convert that.

In many cases, it will be better not to do this and to start the LaTeX coding from scratch.

However, there are cases in which it can be useful to convert them because, for example, you are provided with a form in .doc(x) format, and need to complete this form regularly. You could turn this into a .dot(x) - at least, if you have Word, you could do this or, if you are like me, you could use LibreOffice instead. Or you could, if you are sufficiently bloody-minded about the whole thing, insist on converting it to a .tex document which you then treat as a fill-in 'template'. And, bloody-minded or not, you might want to merge data to fill multiple forms and have no idea at all how to do that in a word processor but understand perfectly how to use textmerg. If so, a one-time loss of efficiency in converting the form may easily be worthwhile in terms of saving your time and hair later. The mere knowledge that you do not have to tangle with an alien system over and over again may bring a measure of joy and peace to your existence. The knowledge that you never again need fill in the data on triplicate carbon copies by hand or dive into the Auto-Correct Nightmare may enable you to banish the most insidiously pointless of your bureaucratic traumas.

Now you could make it into a proper class or style. That's The Right Way to LaTeX It. But, frankly, life is sometimes too short to worry overly much about ensuring that institutional forms are created using clean code. Especially when they must look exactly as if they were created in Word in order to be acceptable to the institution.

In these circumstances, automatic conversion and minimal clean-up is the way to go.

In these circumstances, wvware does a very good job of producing messy code which produces PDF which looks every bit as bad as the Word original: too tight spacing, crowded tables with gray, shaded bits in odd configurations: you name it, it converts it.

It probably actually does a better job if the original document is logically constructed. I'm guessing all the \textbf{}s I get reflect real changes in the original document which the converter cannot tell are entirely pointless.

The result is an admirably high-fidelity clone of the original, including all aesthetic and typographical atrocities, and thereby ensuring conformity with the most exacting of institutional requirements.

This conversion software has preserved what little sanity I have in the face of institutional paperwork requirements. I highly recommend it to anybody faced with similar organisational demands.

cfr
  • 198,882
  • 1
    I took the "turn it into a document class and use datatool approach" for a form my department suddenly invented. But although it mimics the Word created document, mine is Just A Little Bit Nicer Looking.™ :) – Alan Munn Jan 15 '16 at 23:51
  • @AlanMunn So is mine, actually. But only in ways which nobody can consciously notice or, therefore, object to. Mine isn't a class. It is basically a .tex document which I copy and modify. Then merge stuff into. I suppose I could make it a class, but I guarantee they'll change the form if I do that ;). (Actually, I have more than one, sadly....) – cfr Jan 16 '16 at 00:23
  • Note that the wv site recommend not to use the wv* scripts, it encourages use of AbiWord (a heavy user of the ẁv` library under the hood). – vonbrand Jul 08 '21 at 22:43
2

Yes, there is a tool. I just came across GrindEQ while looking for an automatic tool myself:

www.grindeq.com

They have a version that you can install in your computer or an online service for conversion. It is not free though.

Mensch
  • 65,388
rimejal
  • 29