### Who is online

In total there are 11 users online :: 1 registered, 0 hidden and 10 guests (based on users active over the past 5 minutes)
Most users ever online was 1327 on Tue Nov 05, 2013 7:11 pm

Users browsing this forum: Bing [Bot] and 10 guests

## Copy/paste text maintaining formatting

Add tags Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)

### Copy/paste text maintaining formatting

Hello,
how can I copy/paste text from Microsoft Word or a web site maintaining its formatting? (e.g. italic, bold etc)

A specific thing I'd like to maintain is the paragraph division, in order to avoid to do it manually.

Thank you
Last edited by ffarr on Wed Apr 27th, 2011, edited 1 time in total.
ffarr

Posts: 28
Joined: Sat Apr 23rd, 2011

### Re: Copy/paste text maintaining formatting

You can try writer2latex, which works nicely with Libreoffice (which is free software, so you can give it a try without having to pay a cent). I've found this solution to be quite satisfying. However, be aware that sometimes resulting .tex file can be pretty messy, depending on the complexity of the source document.

Regarding paragraph separation, I'm not sure what's the deal? If you want paragraphs to be separated by vertical space instead of first line indent, simply redefine parindent and parskip lengths, e.g.:
Code: Select all  •  Open in writeLaTeX
\setlength{\parindent}{0pt}\setlength{\parskip}{12pt plus 2pt minus 2pt}

meho_r

Posts: 823
Joined: Tue Aug 7th, 2007

### Re: Copy/paste text maintaining formatting

Maybe I wasn't very clear, I beg your pardon for my poor English.

What do I have to do?

I have to copy text FROM word TO LaTex (in my case, I'm using TeXnicCenter)

What's the problem?

The problem is that, after pasting it in TeXnicCenter, I have to manually modify it. I've got to put the bolds, italics etc, to change all the ' ", to separate manually the paragraphs, inserting a blank line among them.
When I copy some text from word to TeXnicCentre, the result is text without formatting and without line breaks.

Is there a way to automatically obtaining formatting in TeXnicCentre?
ffarr

Posts: 28
Joined: Sat Apr 23rd, 2011

### Re: Copy/paste text maintaining formatting

meho_r wrote:You can try writer2latex, which works nicely with Libreoffice (which is free software, so you can give it a try without having to pay a cent). I've found this solution to be quite satisfying. However, be aware that sometimes resulting .tex file can be pretty messy, depending on the complexity of the source document.

Regarding paragraph separation, I'm not sure what's the deal? If you want paragraphs to be separated by vertical space instead of first line indent, simply redefine parindent and parskip lengths, e.g.:
Code: Select all  •  Open in writeLaTeX
\setlength{\parindent}{0pt}\setlength{\parskip}{12pt plus 2pt minus 2pt}

Ok I'll try you tip.
About paragraph separation: my problem is that when I past the text I have to manually insert paragraphs breaks (I do it putting a blank line between them), it's not about the separation in pts.
ffarr

Posts: 28
Joined: Sat Apr 23rd, 2011

### Re: Copy/paste text maintaining formatting

Your understanding of how TeX works is wrong. It processes files which are written in plain text. Did you try to copy formatted text from a word processor into a simple text editor? Did it preserve the formatting? I guess not. And even if it would do so, this wouldn't help you. (La)TeX is a typesetting system with a markup language that passes its formatting by commands to the compiler. And by the way, this isn't really a LaTeX problem but more a problem between an editor and a word processor. LaTeX editors simply neglect all formatting tags from the clipboard. And what did you expect? That after you copied italicized text from a word processor to your LaTeX editor and this would insert \emph{italicized text} or \textit{italicized text} to your source code? Then you are off the track.

Thorsten
LaTeX Community Moderator

¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

localghost
Site Moderator

Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

### Re: Copy/paste text maintaining formatting

I understand your point, but I'm afraid you don't get mine.

I have to convert a lot of text in TeX and right now if I copy:

Code: Select all  •  Open in writeLaTeX
Lorem ipsum.Lorem ipsum.

I obtain (in the PDF):

Code: Select all  •  Open in writeLaTeX
Lorem ipsum. Lorem ipsum.

So in TeXnicCenter I have to put:

Code: Select all  •  Open in writeLaTeX
Lorem ipsum.Lorem ipsum.

When you have to do it manually one thousand times, it's a bit annoying..
ffarr

Posts: 28
Joined: Sat Apr 23rd, 2011

### Re: Copy/paste text maintaining formatting

ffarr wrote:I understand your point, but I'm afraid you don't get mine. […]

But I think I got you at least halfway. And in your initial post you talked about italics and bold text. TeX interprets the contents of input files in a certain way. And this is one of them. New paragraphs are introduced by a blank line, not only by a carriage return. Conversion tools may help. Otherwise I'm afraid you will have to live with it if you want to continue using TeX.
LaTeX Community Moderator

¹ System: openSUSE 13.1 (Linux 3.11.10), TeX Live 2013 (vanilla), TeXworks 0.5 (r1351)
² Posting stopped indefinitely due to offenses

localghost
Site Moderator

Posts: 9219
Joined: Fri Feb 2nd, 2007
Location: Braunschweig, Germany

### Re: Copy/paste text maintaining formatting

Simply put:
1. If you want to preserve formatting completely or partly, conversion is probably the only way.
2. If only paragraph separation is important, you can use regular expressions to replace carriage returns with carriage return + an empty line. E.g., in LibreOffice/OpenOffice.org that is achieved by searching for $and replacing it with \n\n (of course, with "regular expressions" activated in the search dialog). You can use regular expressions to mark italics/bold too, e.g. Search for (with formatting set to italic): (.*?) Replace with: \emph{$0}

meho_r

Posts: 823
Joined: Tue Aug 7th, 2007

### Re: Copy/paste text maintaining formatting

Actually, writer2latex for liberoffice works fine for me, so I'm going to mark this thread as resolved.

Thank you all!
ffarr

Posts: 28
Joined: Sat Apr 23rd, 2011