1

There are many posts in the forum with both LaTeX source code and the resulting images from compilation. Can anyone point me to the resources on posting questions in this format?

I would like to post a question involving LaTeX source using text commands with the resulting compiled image. I'm unsure if the compilation process must be done on my end and image manually uploaded, or the LaTeX can be included inline with the post (which would be compiled automatically). I tried latex2html, however noted that many figures and latex commands showed up incorrectly. I also realize there is MathJax or the dollar sign to include mathematical notation, however understand this only covers math equations.

Thank you!

  • 3
    this would be better asked on the meta site, but the answer is post the code as text and then post a clipped image from your pdf viewer to show the output – David Carlisle Apr 30 at 18:20
  • 1
    This has been discussed many times before, and the consensus is that it cannot be done correctly because versions and features of LaTeX and packages are always changing, and also because in questions people often have some kind of error which would not be useful to compile on the site, and that it would be confusing for new users on the site. Another counterargument is that Stack Exchange would never implement this because they don't do custom functionality for individual sites. – Marijn Apr 30 at 20:30
  • I personally disagree with this, I think that it would be useful, especially for answers, to compile on the site and to include the result if it corresponds to your own output. This would make it easier and faster to include results in a post. However, it would not be a very big improvement, it is not very difficult to make a good screenshot yourself and upload that. – Marijn Apr 30 at 20:35
5

Getting Help

If you ask a question you will have short "How to Format" in the yellow box right beside the editor box:

How to Format

The link formatting help (in the image above I've put the mouse over it) leads to a more detailed page with examples.

The editor field also has a toolbar:

Toolbar

Here you can also find a button to get markdown editing help:

Markdown Editing Help

Also note the help center button in the top menu of the page:

Help center etc.

How to Format Code Using the Toolbar

  • Copy some code to the editor field, separated by one empty line from the text above. Nevertheless, in the editor field it will be shown a spaghetti code without any formatting:

Code without formatting

  • Select the code with you mouse and click to the code button {} in the toolbar:

Selected code and code button

  • Now your code will be indented by 4 spaces and the preview below the editor field will show nice code:

Formatted code

How to Add an Image Using the Toolbar

  • If you want to add a screenshot make it and save it as PNG or JPEG. Some PDF-viewers also allow you to export pages as PNG or JPEG. You can use any paint/image software (e.g. GIMP) to add additional information to the file. Currently TeX.SX does not provide making PDFs/images on the fly. So you have to compile the TeX code either using you own TeX installation or an online editor like overleaf. Use tex4ht, latex2html only if they are part of the problem, because mostly the will not generate the same result as your preferred TeX engine.

  • Place the editor where you want to add the image and click to the image button in the toolbar:

image button

  • Click to "Browse":

browse link

  • Select the file you want to add. A preview of the file will be shown. You should verify, that it is the correct picture, before you click to "Add picture":

Preview

  • Something like [![enter image description here][1]][1] will be added at the cursor position an something like [1]: https://i.stack.imgur.com/4AtI7.png at the bottom of your question. And the preview below the editor field will show the image.

Image added

  • Last but not least, you should replace "enter image description here" by an alternate text, e.g., "left aligned blackbox with centered caption text".
1

Based on suggestion, the answer is "post the code as text and then post a clipped image from your pdf viewer to show the output".

  • 1
    don't forget to indend the code with 4 spaces to mark it as code. Fastest way to do is select all code and press the button with {} on it – user187808 Apr 30 at 21:08

You must log in to answer this question.

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