4

I have a LaTeX file called testglister2.tex in my directory ~/GlisterBook. How do I import it into TeX.SE as an MWE? I use emacs as my text editor and from there I can copy the file, but how do I paste it as an MWE?

10
  • 1
    paste it in then highlight it and hit control-k (which just indents by four spaces to mark as a code block) Jul 8, 2019 at 19:35
  • @DavidCarlisle Aye, there's the rub. How do I paste it in? I'v tried with ~\GlisterBook/trestglister2.tex but SE responds with something like file extension not recognised. Jul 8, 2019 at 19:44
  • just M-w in emacs to copy the region to your system clipboard then control-v or whatever you system browser keybinding paste is to paste it into the browser Jul 8, 2019 at 19:50
  • 3
    that is, don't upload the file, just paste in its contents. Jul 8, 2019 at 20:30
  • 1
    An alternative to the four-spaces indentation is to write ```latex on a single line in the question or answer text box, then paste your code, then add ``` on a single line. This is convenient if you later decide to update the code: you can then simply select everything between ```latex and ```, delete it and paste the new code at the same place (moreover, in most modern GUI programs, the delete operation is automatic when a selection is active and you perform the “paste” action). This syntax also works inside list items if you indent all such lines by four spaces.
    – frougon
    Jul 8, 2019 at 21:25
  • On Linux you can pipe the file into cURL to upload it to a paste service directly, e.g. dpaste: cat trestglister2.tex | curl -s -F "syntax=tex" -F "content=<-" http://dpaste.com/api/v2/ The resulting link you can then post on TeX.SX. Jul 9, 2019 at 1:51
  • 2
    @HenriMenke true but posting inline in the question is much preferred over posting a link to a transient website paste link (if I understand your intention here) Jul 9, 2019 at 8:50
  • @DavidCarlisle To me it sounds as if the file was very large and Ctrl+C / Ctrl+V is not desirable. Jul 9, 2019 at 9:50
  • 3
    @HenriMenke hmm but a _M_WE shouldn't be that big:-) Jul 9, 2019 at 10:14
  • @DavidCarlisle A combination of your first (control-k) and third (control-v) comments worked for me. Do you want to present them as the answer. As an aside the code I wanted to show identified a problem when moving from 2018 LaTeX to 2019 LaTeX, but Karl Berry has since identified a solution. However, if desired, I could still post the problem. Jul 9, 2019 at 17:23

1 Answer 1

7

There is no file upload but you can paste the text from your editor then mark as a code region.

Select the text in emacs (eg M-w to copy the current region) then (assuming you are using an emacs with bindings to your operating system GUI) that will be on the system clipboard so you can paste it into a text box in the browser (typically with Ctrl-V) then while it is highlighted, you can type Ctrl-K which will indent the text by four spaces which is (one of the) markdown syntax to mark it as a code block with preserved white space and line ends.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .