The code of code blocks copied from PDFs is not correct #4008
-
I use code blocks a lot for my course material, and so students want to copy it to use. On the HTML versions of my Quarto content, it's no problem (the copy icon is awesome). However, in PDF it's another story. Here's a simple example: # Some sample java code
```java
ArrayList a = new
ArrayList();
``` If I copy the code from a PDF of the above, and paste it into a text editor, I get:
The missing line break will cause an error because two tokens run together. Plus, there's a It's probably (surely?) related to LaTeX, and there are several discussions I found, but didn't have time to try out all the options: Any advice (using a different way to display code in LaTeX that has more reliable copy/paste?) would be helpful. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
One quick thing for you to try - I saw the same paste behavior that you described using the preview that we generate, but when I open the PDF using the system PDF viewer, the code pasted correctly as:
Do you see the same thing? Not sure whether students will be using the preview instance vs. a distributed PDF in a desktop viewer, but could potentially reduce the problem. |
Beta Was this translation helpful? Give feedback.
-
Have you had any further luck in solving this issues? I'm also distributing course material via PDF to students and would prefer to have them copy and paste easily from the document, regardless of the application they are using to view the documents. |
Beta Was this translation helpful? Give feedback.
One quick thing for you to try - I saw the same paste behavior that you described using the preview that we generate, but when I open the PDF using the system PDF viewer, the code pasted correctly as:
Do you see the same thing? Not sure whether students will be using the preview instance vs. a distributed PDF in a desktop viewer, but could potentially reduce the problem.