7

I frequently run into code posted to this site which I'd like to see in rendered form in order to quickly decide whether it fits my needs.

Opening a document just to do this often feels like a hassle. Are there any plans to add the ability to, for instance, just hover the cursor over a block of code or press some button below it and have a popup appear that shows what the output looks like?

  • 8
    to be able to provide the rendered output would require a full latex implementation in the background of the stackexchange site. that's not likely to happen. when i've answered questions that involve examples, i've usually tried to include an image of the output (.png files are easy to add to a question or an answer), and i think that's the most reasonable thing to expect. but it is up to those who are answering questions to "do the right thing". – barbara beeton Sep 24 '16 at 18:40
  • 6
    In addition to what @barbarabeeton says, the issue with a LaTeX set up here is that package versions will vary, and that means for any issues we have the problem of not being able to match people's local set ups. – Joseph Wright Sep 24 '16 at 18:43
  • @barbara Could you explain, why it's not likely to happen? It doesn't seem like an impossible feat to render every block of code in a question or answer upon posting and attaching the result to that post in order to show it upon request as described above. – Casimir Sep 24 '16 at 18:44
  • 6
    as @JosephWright has pointed out, not everyone has the same versions of all packages and fonts; in fact, a number of the packages mentioned in questions (and answers) aren't posted on ctan, and many fonts are commercial. there's absolutely no way to keep such a system in workable condition for such a varied user base, even if there's a tex-knowledgeable staff willing to try. – barbara beeton Sep 24 '16 at 18:50
  • 3
  • 2
    Not every code block can be compiled out of the box. Suppose an answer suggests to use \donotincludeinmaintoc, that will give undefined control sequence, because the package defiing the command would not be loaded. – Johannes_B Sep 24 '16 at 22:51
  • When I don’t want to create a new file on my hard drive, I just paste the example into Gummi. Then I can quickly see whether it works on my system, whether the output looks as I’d hoped, and whether it’s worth saving as a file or can be discarded. (Quick testing of examples here is the only reason I have Gummi installed, since I prefer writing documents in Emacs.) – Thérèse Oct 1 '16 at 23:21
  • 4
    We have discussed this a zillion times, I don't think there's any reason to discuss it again. Voting to close as a dupe of Why doesn't maths render as maths? – yo' Oct 2 '16 at 5:01
16

This would be very similar to requesting MathJax support, which has been declined here as we're more interested in the code rather than the output. That doesn't mean the output is not important, of course.

Moreover, many of the code posted by users here contain errors which they don't know how to correct. Or, it contains customizations that are found outside of the default distribution(s).

Stack Overflow implemented something similar as a feature request, although limited in language scope. The extendability of (La)TeX as well as it's different compilers would be difficult to implement easily, if at all.

It's best if users can add an image of the output they see (or expect to see) as pictures are often worth a 1000 words.

  • 1
    Now that you mention it, the lack of MathJax support has been bugging me once or twice before as well. I wouldn't say that I'm generally more interested in the code than its output. Rather, I judge the first by the second. – Casimir Sep 27 '16 at 4:10
  • 3
    @Casimir -- mathjax output often doesn't adequately represent latex input. therefore, it is of relatively little interest here. however, the output from latex is important, but it's up to the poster to provide it. – barbara beeton Sep 27 '16 at 12:22
  • 1
    That may be so but during the occasions where I would have appreciated the ability to use MathJax, my intention was not to simulate rendered LaTeX code but to refer to e.g. labels like z_1, m^2, p_0^2 in a TikZ diagram or something similar. In such cases, it doesn't really matter if the MathJax output doesn't exactly reproduce the LaTeX output, it would just circumvent cluttering up posts with underscores and circumflexes. – Casimir Sep 27 '16 at 12:30
  • 1
    @Casimir: It's probably unlikely to provide full MathJax support and assume people will only use it the way you suggest. People will try to post complete minimal documents containing TikZ customizations and loading external files, then questioning why MathJax doesn't show the output they see on the local system. You may only have these good intentions, but from a network point-of-view, it's all-or-nothing, and the "all" isn't really "all" in this case. – Werner Sep 27 '16 at 14:52
  • 1
    @Casimir You can get simple subscripts for such uses, without using mathjax: z<sub>1</sub>, m<sup>2</sup> (in posts, not in comments, unfortunately) – David Carlisle Sep 27 '16 at 23:36
  • @DavidCarlisle That's cool, thanks for the tip. I'll try that next time it comes up. – Casimir Sep 28 '16 at 4:45
  • I agree with the "a picture's worth a thousand words" sentiment. Those who answer questions are often very good at giving details or responding if the asker has further questions about how to implement the solution. Also, if a command is unrecognized, a simple web search can yield a result on it -- and this leads to more user self-sufficiency, which I think is a very good thing to encourage. I've learned more here by having to figure out a few things by myself, than being given a copy/paste solution. It's really so much better in the long run. – J.D. Oct 2 '16 at 21:36
2

As @paul-gessler has commented, this has been asked several times before, and the community of TeX.SE is generally against such a feature, mostly because of problems with erroneous code, compatibility, or output that requires multiple files (like bibliographies).

However, I am strongly in favour of this feature, if it is implemented with a separate syntax. In this way a normal code block is be shown as code, which is indeed the most sensible behaviour for this site. However, if the user wants, the output can be shown as well. For example:

# \documentclass{article}
# \begin{document}
# Hello World
# \end{document}

Analogous to the syntax for block quotes.

This would save time for almost every time you post an answer where you want to include a screenshot of the output. Creating a new file, copying the MWE, compiling, making the screenshot, cropping, saving, uploading sometimes takes me more time than answering the question itself (for example with answers like "use \phantom") and I do this for practically every answer. Another use case is in-line code, like "the $\sum_{\alpha\in\{-5,-10\}\cup\mathbb{Z}^+}$ is not aligned with the $\sum_\beta$".

TeX.SE could support for example something analoguous to the texlive-full package in Ubuntu. This supports almost everything. If the result is different from what the OP or the answerer has on his own system, then he can choose to show a screenshot instead. If the question or answer depends on a specific engine, command line options, fonts installed, ..., then a screenshot can be used. But in the many, many cases where the setup doesn't matter, the users can benefit from a compilation feature.

  • 3
    just measured. Takes me 6 seconds to take a screenshot and add. Shorter on Linux. – percusse Sep 28 '16 at 13:39
  • 3
    And how much time would we spend undoing edits which added the hashes to code which did not compile with SE's TeX? And what would happen when SE updated their TeX installation? Presumably existing compilations would remain, but what if I edit a minor content typo in code which compiled with the old version but no longer does? – cfr Sep 29 '16 at 1:38
  • 1
    Or edits which added hashes to code blocks without duplicating them so that a post which included code no longer did? – cfr Sep 29 '16 at 1:39
  • 3
    Latex-community has a button to open code blocks with Overleaf, the online editor. That is quite neat sometimes and the user can choose to do it or not. That would be a Feature i would Support on TeX.SX. – Johannes_B Oct 1 '16 at 10:45
  • 1
    @Johannes_B But that is very different from rendering it inline. – cfr Oct 1 '16 at 22:33

You must log in to answer this question.

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