Here is my primary thought. Wish it could bring some inspirations.

First suppose we already have a `Text`

-style Cell, then use the menu **Copy As** -> **LaTeX**:

Paste the content into a pair of quotation marks and clear extra line-breaks:

```
str = "\\text{Let }
...
\\text{, but need some text after it.}" //
StringReplace[#, "\n" -> ""] &
```

We get strings suitable for math-mode:

```
"\\text{Let }M\\text{ be a }\\text{TM}\\text{ and let }A\\subseteq \
\\{0,1\\}^*\\text{. We say that }M\\text{ decides }A\\text{ if \
}\\forall x\\in \\{0,1\\}^*\\text{, }x\\in A\\Rightarrow \
M(x)=1\\text{, }x\\notin A\\Rightarrow M(x)=0\\text{. We say that \
}A\\subseteq \\{0,1\\}^*\\text{ is decidable if there is a \
}\\text{TM}\\text{ that accepts it. And here is an inline complicated \
formula: }\\sum _{k=1}^n \\frac{1}{f(k)}\\int_{\\alpha }^{\\beta } \
\\sqrt{g(x)} \\, dx\\text{, but need some text after it.}"
```

Then we reverse the "environment":

```
str2 = StringReplace[str, RegularExpression["\\\\text{(.*?)}"] :> "«$1»"]
str3 = StringReplace[str2,
RegularExpression["»(.*?)«"] :>
If[StringLength["$1"] == 0, "", "\$$1\$"]] //
StringReplace[#, {"«" -> "", "»" -> ""}] &
```

Then **Copy As** -> **Plain Text**:

Past into SE editor:

Let $M$ be a TM and let $A\subseteq \{0,1\}^*$. We say that $M$ decides $A$ if $\forall x\in \{0,1\}^*$, $x\in A\Rightarrow M(x)=1$, $x\notin A\Rightarrow M(x)=0$. We say that $A\subseteq \{0,1\}^*$ is decidable if there is a TM that accepts it. And here is an inline complicated formula: $\sum _{k=1}^n \frac{1}{f(k)}\int_{\alpha }^{\beta } \sqrt{g(x)} \, dx$, but need some text after it.

Though looks working, this procedure is very primary and buggy. *e.g.* The $TM$s in the original `Text`

Cell are actually in math-mode (*i.e.* inputted after a `Ctrl`+`9`), but they were converted to text-mode when copy as LaTeX. And when the paragraph ends with a formula, it should be take care of with special rule.

3Just to get the correct string before programming anything: I guess you're missing

`\(`

before the second`M`

and`\)`

after the following`A`

. – einbandi – 2012-11-20T15:21:08.020I pasted it back in. It returns $Aborted. – M.R. – 2012-11-20T20:59:57.407

The first thing I tried was copying the text cell as LaTeX, but it didn't work. Gave this message: TeXForm::unspt: TeXForm of Map[System

`FEDump`

TransformBoxesToTraditionalFormBoxes[System`FEDump`

processBoxesForCopyAsTeX[{TextForm},TextData[#1]]]&,<<14>>, if there is a TM that accepts it.] is not supported. >> – M.R. – 2012-11-20T21:04:20.423