# Cut and Paste Non-Math Text from MS Word to a .tex file

I am helping a friend use LaTeX to generate a book of short stories. The stories are received from the authors in MS Word -- unfortunately that is only text editor most of the world knows. There is no math content to worry about, just plain text. However, Word likes to convert some plain text into other characters: The two that I have noticed so far are the quotes and ....

I tried the suggested approach of using inputenc without any success even with various input encoding. I am using \inputencoding as opposed to a package option as I feel as if I might need to change them between various stories.

So, what is the suggested approach to handle this? Ideally, I'd prefer to have some way of mapping these characters to the appropriate LaTeX friendly ones.

## Notes:

• I personally don't like leaving the smart quotes as there are cases where the authors have missed a closing quote and then all the subsequent quotes are incorrect. If this is caught early on, it can easily be corrected in the Word doc before pasting into a .tex file. But often, the editor has made significant edits to the .tex file before this problem is noticed. Hence, the preference to have csquotes handle this problem rather than using the specific open and close quotes.

## Code:

\documentclass{article}
\usepackage{inputenc}
\usepackage{csquotes}
\MakeOuterQuote{"}

%\inputencoding{utf8}
%\inputencoding{latin1}
%\inputencoding{ansinew}
\inputencoding{cp1252}

\begin{document}

"It's too late now…" (should have \ldots\ before end quote)

“Please, sir, don’t.”  (should have left and right quotes)
\end{document}

• Perhaps the best way would be to import in Libre Office, convert to odt format and then use writer2latex. – Bernard Oct 3 '14 at 0:59
• At the end, for complex texts often the best form me is convert to plain text and build the LaTeX file from here. One could obtain more or less good conversions through .odt, .html or .rtf files but also lot of garbage/odd coding that need a lot of manual work. The exception are texts (even simple texts) with tons of emphasized words, lists, etc. that must be maintained, so making this from the scratch is very tedious. Then export to "very simple LaTeX article" in LibreOffice or may be with Abiword could be a good starting point. – Fran Oct 3 '14 at 8:19
• What's the question here? I'm not sure what's the problem. It does compile fine here, if I save the document with utf8 encoding, then utf8 encoding works well, and the same for cp1252. – Manuel Oct 3 '14 at 9:21
• @Manuel: I found the problem -- see comment I left Ulrike's answer. – Peter Grill Oct 3 '14 at 23:05

### Regarding the inputenc question

Your example works without problem if I copy it in an utf8-document and declare the inputenc encoding accordingly as utf8. Ditto with ansinew.

I can't really imagine how you could get the output in your image -- it can be created but imho not with the standard files. None of them would replace non-ascii chars with question marks.

### Regarding quotes

Straight quotes (") are active in german tex documents and used for a lot of useful things like adding break points and hyphens. So I would never use them for real quotes and I prefer word files with smart quotes. When copying from word with (german) smart quotes to tex I use \MakeAutoQuote{„}{“} in the tex document. As such quotes creates a group I get warnings or errors if the smart quotes in word document are not correctly balanced which avoids most errors. But word files are never perfect and so an simple copy & paste is never enough. One always has to read and check the result.

• I guess my problem is how do I copy it into an utf8 document. Using TeXShop's File/New menu and pasting the above MWE (with \inputencoding{utf8} does not seem to do it. – Peter Grill Oct 3 '14 at 18:36
• I think I found a fix. Adding % !TEX encoding = UTF-8 Unicode as the first lines fixes the problem. I guess I had the incorrect encoding set up in TeXShop. – Peter Grill Oct 3 '14 at 23:03

this is the kind of job I use to do sometimes. Well, there are few tools you can use for solve this. Maybe the best and automatic way is with pandoc, but sincerely the truth is that I have not tested enough and have not had a satisfactory experience with it yet. Another choice is to do what @Bernard suggests.

Formerly I used AbiWord for open doc files and export int LateX, it was not a nice solution for me because doesn't respect the document structure and all the diacritics are coded in ascii mode. Bot perhaps for a short text in english could be a good option.

What works best in my experience and I like to pass text from Word to LaTeX is Sublime Text 2. Yes, perhaps for others is stupid and not the best solution, much less automatic, but it works pretty well.

The first advantage I find is that allows you to handle with encodings. You can open a file using the encoding you want (or almost) and re-encode it to whatever you need, usually I spend all to utf8. You can still reopen it or save it with encoding you need and not get weird symbols such as when you try with Texmaker. (In this case I have it set to utf8 and whenever I open a file let me know if it is in another encoding).

The second advantage has to do with the color schemes and the syntax. By default uses a pretty scheme called Monokai, I use to switch to Monokai bright (the difference is the color used for the highlighted selections, in Monokai bright is orange instead the gray by default). The syntax for LaTeX is very comfortable to the eyes and also let us detect easily the quotation marks. Surelly we can achieve the same in vim or emacs but here is very easy. If whe have the common and wrong quotation marks " then Sublime Text with this color scheme highlight the text between in a lively pink color. So is very easy to see where we have to make corrections. Unfortunately if the author or the editor forget to close the quotes, we don't see them in color, but the editr allow us to find them all easily yet. When the quotes are right composed in the ascii mode:  '' we'll see the text in yellow instead of white.

The third advantage has to do with the simultaneous use of cursors in real time, and the use of regular expressions that allows to quickly correct many things, for example the ellipsis. You can select the ... writed in Word and using [Ctrl]+[D] ([Cmd]+[D] in Mac) for select all occurrences in the document, and once selected change it to \ldots just writing it. So the change is not in one but in all selections at once. Fast and easy.

You don't need any special tool for achieve this, but you can also enhance the editor for compile directly on it if you want or for get more tools, yopu can do that installing the Package Control and with it easily get LaTeXTool package and another.

I know that this editor is very popular among people who do web, but I think for LaTeX also has some interesting features, try it and see if it convinces you.

For achieve correctly all this I told before, I usually use both packages: inpuntenc(with utf8) and fontenc(with T1 is enought for western european languages without maths).
• I tried to share my experience with the tool that let me work better when I have to edit texts from MS Word until now. I certainly have not tested enough yet Pandoc I guess is the logical and preferred choice of most. And about the tools I've used, this is what has worked best for me, and I tried to explain some of the reasons why. But well, the answers can also be edited if they are not quite right. – Aradnix Oct 3 '14 at 6:33
Pandoc is a command-line tool that can covert docx files to LaTeX files. As for dealing with ellipses and quote marks, I think that the best way to handle those is using the search and replace function in your LaTeX editor.
• I just tried the online pandoc conversion of the above content and while the quotes and \ldots were correctly converted, the new line was removed. It would be preferable to not do a conversion if at all possible. – Peter Grill Oct 3 '14 at 1:27
• @PeterGrill If you copied the text from Microsoft Word into the online converter, then you can expect the formatting to be garbled as it is copied from Word into your browser. The only way to test this is to install pandoc on your computer. – ChrisS Oct 3 '14 at 9:24