# Split A text-style cell to multiple cells by a fixed width

Sample Cell 1

Cell["Much of point set topology consists in developing a convenient language to talk about when various points in a space are near to one another and about the notion of continuity. The key is that the same definitions can be applied to many disparate branches of math.", "Text"]


Split to multiple cells like

Sample Cell 2

Cell["Much of point set topology consists in developing a convenient", "Text"]
Cell[" language to talk about when various points in a space are near", "Text"]
Cell[" to one another and about the notion of continuity. The key is", "Text"]
Cell[" that the same definitions can be applied to many disparate ", "Text"]
Cell["branches of math.", "Text"]


Though, in this example, they are all plaint text, maybe much simpler, the problem might be harder when there are many inline math cells.

Here is an sample post for why I need this, I wanna make first light-green block text into multiple framed lines like what below Definition 4.1.1. http://quaternions.blog.163.com/blog/static/206082147201356102512774/

Bill's present method will not able to deal with the inline cells.

Upadte sample Cell 3 with inline cells

Cell[TextData[{"Much of point set topology", Cell[BoxData[$$TraditionalForm\\(\ consists\$$\)], FormatType -> "TraditionalForm"], "in developing a convenient language to  talk about ", Cell[BoxData[$$TraditionalForm\when$$], FormatType -> "TraditionalForm"], " various points in a space are near to one another and about the notion of ", Cell[BoxData[$$TraditionalForm\\(continuity\^2$$\)], FormatType -> "TraditionalForm"], ". The key is that the same definitions can be applied to many disparate branches of math."}], "Text"]

-

Take the first cell and give it a name:

myCell=Cell["Much of point set topology consists in developing a convenient language to  talk about when various points in a space are near to one another and about the notion of continuity. The key is that the same definitions can be applied to many disparate branches of math.", "Text"]


Here's a function to break it into pieces with about n/2 words in each piece:

breakCell[str_, n_] := Cell /@ StringJoin /@
Partition[Riffle[StringSplit[First[List @@ str]], " "], n]


For example, applying breakCell to myCell gives:

breakCell[myCell, 15]

{Cell["Much of point set topology consists in developing"],
Cell[" a convenient language to talk about when "],
Cell["various points in a space are near to"],
Cell[" one another and about the notion of "],
Cell["continuity. The key is that the same definitions"],
Cell[" can be applied to many disparate branches "]}

-
Hi, bill, there would be some problems when arbitrarily add some inline cells in myCell –  HyperGroups Jun 6 '13 at 3:44
Well... the code is right there -- I just took the First` part. If there's more stuff, you will want to write something that handles that as well. –  bill s Jun 6 '13 at 3:46
en, I should make my original cell just be cell with inline cells –  HyperGroups Jun 6 '13 at 3:49
How about select the part of the cell you want and then choose Cell->Divide Cells from the menu. –  bill s Jun 6 '13 at 4:23
ha, that's too [adj...] for frequent work. Actually I get my Sample Cell2 from Sample Cell1 in that way. –  HyperGroups Jun 6 '13 at 4:26