10

I'm copying text from Microsoft Word and pasting it into my LaTeX editor. I've been manually replacing all instances of italics with \emph{}, but is there a way to do it faster?

The process would need to be able to find all chunks of italics text (both isolated words and strings of multiple words), then add an \emph{ to the beginning and a } to the end.

(I realize this may not be a TeX question directly, but I'm sure other TeX users will find it helpful.)

12

We start by first making a dummy document and hoping that the italics are made by that button that lives between the bold and the underline buttons.

So a dummy text

enter image description here

Then if you can find the %$#&%#?@! Find & Replace button on that ever changing menu like thingy, click Replace

First click in the text box of Find and click Format button and then font. Only click Italics and nothing else. Then OK. OK?

Now click in the Replace box and type \emph{^&}, then click format and font again and select Regular and nothing else.

The result should look like

enter image description here

Then keep your expectations low and click Replace All, I got this

enter image description here

Back in the day, we had to record macros and other kind of VBA nonsense. At least it supports it out of the box. I'm gonna wash my hands now, happy recording :)

| improve this answer | |
  • 2
    I don't have the mental power to make a general example using this fantastic software but you can distinguish section headings etc. and with a little visual(I never understood what is visual about it) basic macro knowledge you can fake a pandoc solution. – percusse Oct 23 '13 at 4:17
  • 3
    Don't forget to take the clothes-pin off your nose, too. – Steven B. Segletes Oct 23 '13 at 10:16
  • 3
    @StevenB.Segletes Sorry I can't hear you behind the gas mask. – percusse Oct 23 '13 at 22:14
3

For a long text, the best option is indeed convert the whole document to LaTeX and copy the chunks of text that you need, as suggest ChrisS, as very probably you will want also maintain some other formats as sections or lists.

There are several conversion methods, but in general, a problem with this approach could be that converted text could be infected of unwanted LaTeX code (color, spacing, font sizes, etc.) included to maintain the Word format, and no just some \emph{} or \textbf{} here and there, so you must clean it manually. Your mileage can vary depending of the conversion method.

At this respect, I obtained very reasonable results opening the Word document in LibreOffice and then export to LaTeX ( menu File > Export > Type of file > "Latex 2e" (you can mark here a chekbox to export only a selected text) > LaTeX format "Very simple article" and play with the other options to avoid superfluous code.

Another alternative is to export to LaTeX but with Abiword. One more: import the Word file in Lyx, show the LaTeX code (menu View) and then select and copy the code with the mouse, or export to LaTeX (menu File > Export).

| improve this answer | |
1

I use pandoc for converting documents to LaTeX; you can run it on your Word document and then copy the specific text you want from the generated LaTeX code.

| improve this answer | |

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.