0

I'm trying to use a regular expression to find and replace italicized text in a long Word document to move the text into a LaTeX document, so I want to replace Word's formatting with \emph{...} syntax. I can use the "Advanced Find" dialog box to search for the italics formatting, but I don't know how to make a substitution to replace this.

For example, I want to automate replacing this:

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

With this:

Lorem ipsum dolor sit amet, \emph{consectetur adipiscing elit}, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

What do I need to do to make this work?

1

You can refer to found text with ^& in Word:

  • press CTRL+H to open "find and replace" dialog
  • select find what box, then select format - font - italic
    • (leave "find what" empty)
  • enter \emph{ in "replace with",
    • select "special" - "find what text" (or directly type ^&)
    • finally type }
  • select "format" - "font" - "not italic"
  • press "replace all"

"use wildcards" should be empty for this to work enter image description here

| 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.