LaTeX forum ⇒ Text FormattingCopy/paste text maintaining formatting

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Copy/paste text maintaining formatting

Postby ffarr » Sun Apr 24, 2011 4:08 pm

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 27, 2011 3:04 am, edited 1 time in total.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Postby meho_r » Sun Apr 24, 2011 5:03 pm

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.:
  1. \setlength{\parindent}{0pt}
  2. \setlength{\parskip}{12pt plus 2pt minus 2pt}

Link:
BBcode:
HTML:
Hide post links
Show post links

ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Postby ffarr » Sun Apr 24, 2011 5:49 pm

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?

Link:
BBcode:
HTML:
Hide post links
Show post links

ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Postby ffarr » Sun Apr 24, 2011 5:56 pm

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.:
  1. \setlength{\parindent}{0pt}
  2. \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.

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Sun Apr 24, 2011 6:47 pm

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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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

Link:
BBcode:
HTML:
Hide post links
Show post links

ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Postby ffarr » Tue Apr 26, 2011 8:12 pm

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:

  1. Lorem ipsum.
  2. Lorem ipsum.


I obtain (in the PDF):

  1. Lorem ipsum. Lorem ipsum.


So in TeXnicCenter I have to put:

  1. Lorem ipsum.
  2.  
  3. Lorem ipsum.


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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm
Location: Braunschweig, Germany

Postby localghost » Tue Apr 26, 2011 9:41 pm

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
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


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

Link:
BBcode:
HTML:
Hide post links
Show post links

User avatar
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Postby meho_r » Tue Apr 26, 2011 10:44 pm

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}

Link:
BBcode:
HTML:
Hide post links
Show post links

ffarr
Posts: 28
Joined: Sat Apr 23, 2011 6:00 pm

Postby ffarr » Wed Apr 27, 2011 3:03 am

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

Thank you all!

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 3 guests