This site is missing an important feature: a button for copying LaTeX
code and co to the clipboard.
-
1My understanding is that this is not really possible in a truly portable way - but I can't be sure, hence posting as a comment not an answer– Joseph Wright ModCommented Sep 27, 2023 at 7:32
-
1@JosephWright it would be possible, but stackexchange powers declined adding it (there's a long thread on the main meta somewhere, I'll find....)– David CarlisleCommented Sep 27, 2023 at 7:34
-
3MSE: Shortcut or button for copying posted code from Stack Overflow– David CarlisleCommented Sep 27, 2023 at 7:35
-
2This would be so useful, I keep meaning to add one of the user scripts that adds it.– David CarlisleCommented Sep 27, 2023 at 7:36
-
2Does this answer your question? Easy way to copy code block?– samcarter_is_at_topanswers.xyzCommented Sep 27, 2023 at 8:06
-
1Another possible duplicate: tex.meta.stackexchange.com/questions/7455/add-button-select-all/…– samcarter_is_at_topanswers.xyzCommented Sep 27, 2023 at 8:07
2 Answers
It would be possible, but stackexchange powers declined adding it. There's a long thread on the main meta:
Shortcut or button for copying posted code from Stack Overflow
This would be so useful, I keep meaning to add one of the user scripts that adds it.
Note that is a very old thread, and some of the earlier excuses for not adding this refer to security. At the time there was no standard clipboard API and the common way was to use a flash plugin which had "interesting" security implications. That hasn't been an issue for a decade or more. All common browsers provide native clipboard access.
If you install a user script (greasemonkey or similar) there are several available scripts that would add a copy button for stackexchange sites, but it would be better if one was there by default (or Ctrl-a Ctrl-c was adjusted to select all of a code block, not the whole page, which would also be possible).
-
2If you are using firefox or chrome, I can recommend github.com/zenorocha/codecopy Commented Sep 27, 2023 at 8:05
-
5I've pinged the Powers to see if they'll look again at this– Joseph Wright ModCommented Sep 27, 2023 at 8:07
-
-
1@projetmbc Indeed! It will also add this to a couple of other websites. Commented Sep 27, 2023 at 8:16
-
I have guessed that this plugin adds a button before
<code>
HTML tags. Commented Sep 27, 2023 at 8:34
After discussing this with the other CMs, we've decided to decline this request. We already has enough issues with folks copying and pasting without attribution, so this would require further investigation to determine whether it would be worth implementing (and how to mitigate the risks). Our developers also have limited bandwidth to investigate and implement this at the moment, so this isn't something that's likely to be implemented in the near future.
For now, you can use the workarounds of simply copying and pasting manually, or using a userscript as others have suggested.
-
15This is really unfortunate. We stress to users that they should include minimal working examples in questions, I've answered 14 thousand of those questions, some with multiple code blocks to make an example, that's tens of thousands of times having to select the start of a code, scroll the div then shift select to get the end. The argument that copying should be made difficult on purpose on a site whose entire purpose is to let people ask other people about some code seems bizarre to say the least. -1, sorry (and I very rarely downvote) Commented Sep 27, 2023 at 16:45
-
3@V2Blast Can you clarify the problem with "copying and pasting without attribution"? How do you try to solve it? Commented Sep 27, 2023 at 16:55
-
5How making copy and paste more difficult could help with attribution, I fear I can't understand. It makes it more difficult to use the code, probably. Going absurd in that direction, you can transform the
<code>
blocks into PNGs... they will be hand-copied the same by people who don't want to attribute and not copied by people who want to help. Just my two cents (and yes, I can use the workarounds, but that means trusting an extension and/or using a specific browser)– RmanoCommented Sep 27, 2023 at 16:56 -
2...and, BTW, GitHub recently added it. I love it when handling issues...– RmanoCommented Sep 27, 2023 at 16:59
-
9Whilst I am disappointed with the answer, thank you for taking the time to provide direct feedback to what is a rather 'insulator' community within the SE network– Joseph Wright ModCommented Sep 27, 2023 at 17:04
-
4To address the specific about attribution, I think that is likely something that makes sense on the main site (SO) but much less here: @DavidCarlisle has noted the point about questions, whilst most code in answers is on TeX-sx targetted at documents written by individuals and unlikely to be redistributed. Moreover, many 'regulars' have a long history of answering posts on Usenet, where the understanding was always 'if I answer, you can use the code for whatever', and many of us have made that explicit in our profiles (I for example say my code is CC0 for this reason).– Joseph Wright ModCommented Sep 27, 2023 at 17:07
-
7A build in copy button could solve the problem of missing attribution: the button could automatically add a link to the post as a comment at the start of the code block. Commented Sep 27, 2023 at 20:38
-
1@samcarter_is_at_topanswers.xyz That would actually be great. I try to be really careful, but sometimes I find I've saved code and forgotten to get the link. However, I guess it would only work on a site-by-site basis and maybe not even that, since the way a comment is marked up varies.– cfrCommented Oct 16, 2023 at 0:25