# How to copy mixture of text and latex formulas in a comment?

Okay, I might sound lazy. When trying to copy mixture of text and latex formulas in an answer, it is always easy. I can simply click "edit" and copy the source. But when trying to do the same in a comment, either others' comment or my own comment after 5 minutes since it was posted, I can copy the source of each latex formula by "Show Source" of MathJax, but when there are more than one latex formula and/or also text to copy, doing this for each part isn't so simple. So I wonder if there is some easy way? Thanks and regards!

I do not know whether I am supposed post this here - since this is tagged feature-request and I am not writing about a new feature. But I think there is quite a simple workaround - when you are viewing the question in your browser, choose View Source (Ctrl+U in Firefox).

You can copy the comments (including dollars) from there. You can search the source for comment or the name of the user, who posted it.

As an example, I've copied the following comments from one of your questions:

For example if $E(X|\mathcal{Q})$ is equal (a.s.) to a continuous function, then the continuous function would be a canonical version.

@QuinnCulver: Thanks! Are you saying if a random variable $Y$ equals $E(X|\mathcal{Q})$ a.e., then $Y$ is a canonical version of $E(X|\mathcal{Q})$? In other words, any version of $E(X|\mathcal{Q})$ is a canonical one?

If the poster of comment used link in his comments and you paste the text of the comment from the source, the link is not displayed unless you delete rel="nofollow". Formatting (bold, italics) seems to be copied well.

A few more experiments:

At first glance, it seems thinking of the numbers in base $p$ will help. Kummer's Theorem will probably help as well.

Comment containing formatting (italics) from here:

I am sorry for chaos confused by my earlier edits. Could you perhaps give a link to the text you're reading or at least to have a look whether the definition of period and index your text is using is the same as in my answer?

Comment containing colors from here:

Show by direct substitution that $x={\color{red}2}$ is a solution to the equation $x^2=x+2$: ${\color{red}2}^2={\color{red}2}+2$.

Probably there are many further problems which can arise with using this method - such as folded comments mentioned by Tim.

Maybe someone will suggest a more straightforward way. The only thing I was able to do was using StackPrinter where all comments are unfolded. I chose the question, but did not print it and instead of printing I viewed the source of the page. From there I was able to copy the comment. E.g. from here I copied the following

No. Since the beginning, I am referring to the fact that you assumed that $(\Omega,\mathcal F)$ is a topological space (with its Borel sigma-algebra), without saying so, although in the canonical probabilistic setting, $(\Omega,\mathcal F)$ is just any measurable space. By the way, to mention continuous random variables like you did in comments is misleading (and I think it did mislead the OP) because continuous here often refers to the distribution of the random variable having no discrete part, and not to the random variable itself, as a function on $\Omega$, being continuous.

Maybe there is a simple way how to display a question (or an answer) with all comments unfolded, but I am unaware of it.

Note that from the source you can also read comment id, which can be used to link directly to the comment in this format: "Show by direct substitution..."

There are other possible ways to do this: either get it from activity tab of that user or, as I've learned from t.b, by using SE Modifications.

EDIT: Comment id and link to a comment can now be obtained simply by clicking on it, see How to link to a comment?

• I found a problem. When trying to copy a comment that is folded by default, I cannot find it in the source after unfold it. If I select that comment to see its source, it only shows part of the comment not the whole. For example, Didier's comment following this reply math.stackexchange.com/q/80334/1281 "No. Since the beginning, I am referring to the fact that you assumed that (Î©,F) is a topological space (with its Borel sigma-algebra), without saying so, although in the canonical probabilistic setting, (Î©,F) ..."
– Tim
Nov 23, 2011 at 21:32
• It's an okay workaround, but far from an easy solution. I'd still prefer a feature. Aug 6, 2014 at 16:45
• @ThomasAndrews By a pure coincidence, I posted (what I consider) an easy solution within 12 hours of your comment...
– user147263
Aug 7, 2014 at 5:55
• This is a test. I am trying to use <i> italics </i> and <b> bold </b> in a comment the way it looks when following the instructions above. Dec 1, 2017 at 13:41

I got sufficiently tired of comment-copying problems to make a bookmarklet Copy all comments to answer box. When used on a question page, the bookmarklet copies all comments under the question to the answer box.

### Features

• Includes the name of each commenter, linked to the original comment.
• Fixes the issue with < becoming &lt;, which was mentioned elsewhere.
• All MathJax and Markdown formatting is preserved.

For example, I used it on the Batman question:

### Detail

The inserted text does not get rendered in the editor's preview window until you modify it, e.g., adding a space.

• Does it copy only comments under the question, or also comments under the answers posted to the question? May 29, 2015 at 10:07
• Only comments under the question.
– user147263
May 29, 2015 at 13:58
• The bookmarklet is currently available here: normalhuman.github.io/stackmarklets Mar 7, 2017 at 18:31
• The bookmark is also available (from March 2106) on the Wayback archive of the first link: Bookmarklets for Stack Exchange. Jul 8, 2018 at 3:30

Another way to get the source of a comment is to use data explorer. (Only works if the comment is already in the database - which is updated once a week.)

You can use this SEDE query: View a single comment based on ID or URL

I learned about this query from the meta.SE question Is there a way to view a comment's source?

And yet another option is simply to post the comment into some chatroom. The comment will be oneboxed and - since MathJax is not rendered in chat. (However, in this way you can only get the MathJax - not the MarkDown.)

You can see how this works for comment right below this answer. Here is the SEDE query - from the results you can get the text of the comment (including both MathJax and MarkDown).

As pointed out in Calvin Khor's answer to another question, it might not be completely straightforward to get the whole text of the comment from the results. One thing you can do is to click on "Download CSV" and then get the text from the downloaded file. Another option is to use the "Text-only results" checkbox.

And I have posted the same comment in the sandbox chatroom - so there you can see how it's displayed in chat. (In particular, it is possible to copy MathJax from the comment.)

• If you need only MathJax - not Markdown - from a single comment, a possibility is simply to post a comment in some chat room where the comment is not distracting, for example, in the sandbox. If the comment contains MathJax - such as $e^x\ge 1+x$ - you can simply copy-paste, since MathJax is not rendered in chat. (However, this does not work for MarkDown.) Feb 7, 2019 at 14:59

I think the following "hack" might be simpler. Suppose you want to copy and paste the following comment:

Right-click on any mathematical formula, and then click Math Settings, then Math Renderer, and then Plain Source.

The comment should then look something like this:

Copy and paste the text as usual, and insert dollar signs around all of the formulae. Once you are done, you probably want to change the renderer back to whatever it was before. You can do this by right-clicking on any mathematical formula, then click Math Settings, then Math Renderer, and click whatever used to have a tick next to it.