10

I have a report written in MS Word which I would like to turn into a LaTeX document. I copy-pasted the content of the document in my LaTeX editor (TeXShop, LaTeX, pdfTeX) and everything comes out fine except for the apostrophes ' which come out as ? (so for example, instead of outputting I'm, I?m is output instead).

In my LaTeX editor, the apostrophes appear as they should, it's only in the compiled pdf document that they are turned into ?.

For a strange reason, I've noticed that if I delete (in the editor) an apostrophe and retype the same apostrophe in the editor, then they are output normally. This trick doesn't work if I do Find and Replace, so the solution I have up to now is simply to manually delete and retype each apostrophe in the text.

This however is very time consuming so I would love to find a better solution!

  • It sounds like your latex file is using an input encoding that's not compatible with your version of MS Word. (Unlike the basic letters and numerals, for which most input encodings use the same representations, this is not the case for "auxiliary" glyphs such as single and double apostrophes.) With a MWE (minimum working example) it's going to be well-nigh impossible to indicate a robust fix to the problem you're facing. Hence, please consider posting such an MWE. Alternatively, you could try a command such as \usepackage[utf8]{inputenc} and see if this solves the issues you're reporting. – Mico Sep 3 '12 at 16:56
  • You should put an example document (at best in a zip-file, so that the encoding is not changed by copy&paste) somewhere for download. – Ulrike Fischer Sep 3 '12 at 16:58
13

Word auto corrects input ' to the typographically correct . LaTeX does this, too.

  1. You can try to search-and-replace all to ' in Word itself or
  2. Use another input encoding, for example UTF8: \usepackage[utf8]{inputenc}
  • Solution 1 worked for me, thanks. – Percy Sep 3 '12 at 21:55
3

I have had such problems too. To me it seems Word does dark replacement magic with all kinds of special characters that are neither "," nor ".". What exactly it does seems to depend on language settings and Word versions.

I'm using my own voodoo to deal with that, amongs which is this sed-script

#!/bin/sed -f
s/\x84/,,/g
s/\x93/''/g
s/\xE2\x80\x98/'/g
s/\xE2\x80\x99/'/g
s/\x85/\\ldots/g
s/\x96/--/g
s/\xE2\x80\x9C//g
s/\xE2\x80\x9D//g
s/\xE2\x80//g

For your purposes the first 4-5 rules should be the most interesting. As always, YMMV.

  • Your script works well if the file is saved in utf8 (2Byte). How can I extend it so that it can works well with utf8 2Byte? – lazyboy Sep 3 '12 at 19:55
  • 1
    I don't understand your question, but if you want to fiddle with character encondings and Word exports, have a look at tidy and iconv. – Bananguin Sep 3 '12 at 20:40
  • Oh, I'm sorry. I means utf-16 (A character is saved in 2 bytes if necessary). But it is not so important. I have a look in tidy and iconv and solved my trouble. – lazyboy Sep 5 '12 at 10:15
  • I'm glad you had your problem solved. UTF-16 is up to 4 bytes IIRC, UTF-8 already can be 2 bytes a character if necessary – Bananguin Sep 5 '12 at 10:41
0

If it was a cut and paste from any source, delete the word, and re-type in the TeX file with the apostrophe. Works for me every time.

  • OP mentioned this approach. The problem is that it's difficult to look through a document and spot where you need to do that. It also "is very time consuming so I would love to find a better solution!" – Teepeemm Jan 18 '18 at 16:16
  • Use search ' , the forward from cursor command, and find all – Patty Bertollini Jan 18 '18 at 16:25
  • "This trick doesn't work if I do Find and Replace." My guess would be that OP typed ' into their "Find" box, which then can't find the different character. It may have worked if they copied the and pasted that into their "Find" box, which could be another answer to this question. – Teepeemm Jan 18 '18 at 17:03

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.