16
$\begingroup$

I found an older thread from 2013 with basically the same question: Using TikZ on math.stackexchange

I'd like to revive the discussion, since I believe it's certainly possible, even if it may not have been back then. That is, can we have TikZ picture rendering? Similar to math formula rendering?

A picture is worth a 1000 words. It would be very nice if we can easily post a picture (through TikZ) without relying on an external drawing program and uploading it in some bitmap format.

As a reference, we can see here how it might work. It's an interactive page that shows some templates.

And here is a vBulletin forum where members can include TikZ pictures in their posts that get rendered server side. Unfortunately you need to be a member to see the images.

$\endgroup$
22
  • 1
    $\begingroup$ "[...] I believe it's certainly possible, even if it may not have been back then." What is the basis for this believe? $\endgroup$
    – quid Mod
    Jul 21, 2017 at 19:29
  • 2
    $\begingroup$ @quid, there is a vBulletin forum that actually has it. I'm currently discussing with its staff it it's okay to share it. When they give me permission, I can provide a link to show how it works on their site. $\endgroup$ Jul 21, 2017 at 19:31
  • $\begingroup$ Thanks for the reply. Idly I wonder why you did not do that before posting the request here. $\endgroup$
    – quid Mod
    Jul 21, 2017 at 19:36
  • 1
    $\begingroup$ My request does not depend on the particular vBulletin forum. As it is I'm exploring since I don't expect this partocular meta forum to be in a position to make it happen $\endgroup$ Jul 21, 2017 at 20:06
  • $\begingroup$ "In any math thread a picture is worth a 1000 words." Highly subjective and debatable. $\endgroup$
    – Asaf Karagila Mod
    Jul 21, 2017 at 20:19
  • 2
    $\begingroup$ Maybe we are talking at crossed purposes. I just want to know what "it" exactly means. For all I know MathJax does still not support TikZ. What does that board do? Do the uses another way to render math? Or do they take the code, create an image server side, and then serve the picture? Or is this a secret? $\endgroup$
    – quid Mod
    Jul 21, 2017 at 23:34
  • 3
    $\begingroup$ I'm sorry @AsafKaragila, but - really? That is, I really do believe that there is no debate that pictures are worthwhile in math threads. Ah well, let people shoot me down if they believe that I'm mistaken. $\endgroup$ Jul 21, 2017 at 23:35
  • 1
    $\begingroup$ @quid, SE recognizes that there are LaTeX markers for math mode and invokes MathJAX to render it. That board recognizes LaTeX markers for TikZ pictures in the same fashion and replaces it by the corresponding picture. $\endgroup$ Jul 21, 2017 at 23:39
  • 1
    $\begingroup$ A picture is worth a 1000 words is a common phrase. See en.wikipedia.org/wiki/A_picture_is_worth_a_thousand_words. Quantifier or not. Forgive me for not applying proper quantifiers. $\endgroup$ Jul 22, 2017 at 0:31
  • 2
    $\begingroup$ I'm looking for some support here for what I believe is a valuable and innovative idea. I should even be able to 'pull' part of the effort (I did on the vBulletin board where I am on staff) - but that will only work if there is at least some support from the community. $\endgroup$ Jul 22, 2017 at 1:41
  • 2
    $\begingroup$ I've added a couple of references where we can see how it can work in practice. Oh, and I've removed the quantifier. $\endgroup$ Jul 23, 2017 at 12:00
  • 4
    $\begingroup$ The corresponding feature request on meta.SE: Can we have automatic TikZ rendering? $\endgroup$ Jul 24, 2017 at 14:34
  • 1
    $\begingroup$ I am not sure that you realize how hard that would be. Consider that the PGF/TikZ manual is 1161 pages long (yes, more than a thousand; this is not a typo). $\endgroup$ Jul 25, 2017 at 14:27
  • 1
    $\begingroup$ @NajibIdrissi I am not sure why it should be that hard to do what I think OP envisions, though this might well be distinct from what others understand the proposal to be. It is I think: suitably marked-up code would be compiled server-side, and the resulting image would be inserted. (The source would be preserved as a commentary or something like that.) Of course this would have some downsides, but this is what is I think proposed. It is also possible I am being naive about the difficulty of that, but it seems plausible to me as one could use existing compilers for the hard part. $\endgroup$
    – quid Mod
    Jul 25, 2017 at 17:07
  • 1
    $\begingroup$ @MarkMcClure how does this make the question off-topic? One would not even have to use MathJax for this. (To be clear, I find the feature request dubious but it's not off-topic; maybe it's a duplicate of the old one, and OP should not have posted it all over the network. But off-topic it is not.) Furthermore, impossible feature requests get declined not closed. $\endgroup$
    – quid Mod
    Jul 25, 2017 at 17:34

3 Answers 3

17
$\begingroup$

Our standard procedure when we get any request for a special site plugin like this is to ask for two things:

  • community support on meta
  • evidence that it would make a significant improvement to post and/or community quality

In other words, we'd like for you to edit this meta question to show us examples of several posts on the site that would benefit substantially from the use of TikZ, and provide explanations of the benefit. (Please account for the fact that Math SE is a fairly high volume site.)

If other people agree with you, they'll upvote, and maybe even start contributing examples of their own. Collect enough upvotes and we can send this to our dev team and say "look, this really is worth your time and the performance cost." (Our devs care a lot about performance.)

For examples, see what our hams did to get CircuitLab enabled (or, for that matter, their request for MathJax).

$\endgroup$
1
  • 2
    $\begingroup$ In the interim it might be worth to check if this is even compatible with MathJax (because clearly this requires an entirely different script to be implemented). The answer might be simple, and it might be a simple "no". $\endgroup$
    – Asaf Karagila Mod
    Jul 25, 2017 at 8:53
17
$\begingroup$

I think TikZ rendering would be a great asset to the site. Well-made pictures can be an enormous aid in learning, from diagrams for path integrals in complex analysis to this image illustrating the proof of the Cantor–Schröder–Bernstein Theorem in set theory. Commutative diagrams in particular are essential in areas such as algebra, algebraic geometry, algebraic number theory, and algebraic topology. To my knowledge, the only package for commutative diagrams currently supported by MathJax is amscd, which is very basic and leaves a lot to be desired. (There are already quite a few threads dedicated to finding work-arounds for this limitation: 1, 2, 3.)

To show that there is demand for TikZ rendering, here are some answers that use images generated by TikZ or the commutative diagram package tikz-cd. (Please feel free to add more.)

Commutative diagrams:

Other pictures:

Here are some to which I might add diagrams if TikZ were supported on the site (and if I were not so lazy).

It's true that I can create an image using TikZ and then upload it, but this is a bit inconvenient (and again, I'm lazy). To do so, I have to:

1) Start my LaTeX editor; 2) Create a new file; 3) Create the image itself; 4) Crop the PDF and save it as a PNG; 5) Upload it to Stack Exchange; 6) Futz around with the size and make sure it looks okay.

Having TikZ support on the site would eliminate all but step 3 (and maybe 6), which would make me much more apt to include pictures in my answers.


In response to quid's comment:

You’re right that in theory steps 1, 2, and 5 take little time. But I’ve been a bit charitable to myself and only included the steps I have to take. Here are all the steps I usually take:

1) Find the TeX file for the most recent image I uploaded to Stack Exchange; 2) Open it and begin modifying it to make a new picture; 3) Realize I forgot to duplicate the file and have instead overwritten it; 4) Duplicate the file and begin modifying it again, while reverting the changes in the old file and recompiling it; 5) Create the new image; 6) Open the PDF in Preview since Adobe Acrobat Reader does not support cropping (the free version available for Mac, anyway); 7) Crop the picture; 8) Try to upload it to Stack Exchange; 9) Realize that although I cropped the image, I forgot to export it as a PNG; 10) Open the image in Preview again and export it as a PNG; 11) Upload the file to Stack Exchange; 12) Futz around with the size and make sure it looks okay.

You might think I’m exaggerating, and it’s true that I don’t make all these mistakes every time I make a picture. But I almost always make at least one (either 3-4 or 8-9).

The resizing part of step 6 of the original list can also be pretty time-consuming. Now that I’ve made a few images, I can finally remember the trick of putting an “m” after the file name to make the picture medium-sized without having to search for one of the meta posts on how to resize images. But sometimes even that doesn’t work well (it didn’t in this one since the figure became too small), and I have to go searching for how to set the picture dimensions exactly using HTML.

$\endgroup$
17
  • $\begingroup$ Just a minor remark about the Cantor--Bernstein theorem proor you suggest is clearer with the drawing, it's actually clearer when you first work under the assumption that $B\subseteq A$, and then deduce the general case. Sure, it doesn't lend itself to this "cross-beam drawing", but it is clearer. One can also use the Knaster--Tarski fixed point theorem to simplify this a bit more as well. $\endgroup$
    – Asaf Karagila Mod
    Jul 25, 2017 at 5:11
  • $\begingroup$ How does the time needed for the steps compare? I usually do not write complicated posts, but if I would I think I'd do 1, 2, 5 for a post without images too. (Where by 5 I mean copy-paste the source.) $\endgroup$
    – quid Mod
    Jul 25, 2017 at 11:11
  • $\begingroup$ @quid I've edited to address your question. Regarding your last sentence, I almost never open my LaTeX editor for Stack Exchange posts unless I’m making an image. If I’m very concerned about losing a long post, I submit the partial answer and then immediately delete it, so I can continue to edit and save it without cluttering the front page. Once I’m done editing, I undelete. $\endgroup$ Jul 25, 2017 at 16:19
  • $\begingroup$ This submit, deleted, continue to edit is poor practice. While it is not explicit in your comment it was in your post that you do so not to clutter the frontpage. But guess what, you do clutter it! If you do not believe it, see why the reopen thread is on the frontpage now. And the more complex functionality we have the more it might happen that lots of tinkering with the post happens as preview does not cut it anymore . This is actually a concern of mine re this feature. Further, I do not see where you actually answer my question re the relative use of time. $\endgroup$
    – quid Mod
    Jul 25, 2017 at 17:22
  • 1
    $\begingroup$ Can you exaggerate even more with the editing process? How about steps 13--600 where you have to battle the ghosts of all the fallen generals from WW2, as well as Stalin, Bismarck, and Nero? What about step 601 which is essentially Ragnarok, where you have to be eaten by Fenris in order to save the Allfather and keep the realms together? $\endgroup$
    – Asaf Karagila Mod
    Jul 25, 2017 at 18:18
  • $\begingroup$ @quid I’m sorry to hear that this still clutters the front page. I can see that you modified the reopen thread, but not how: I assume you edited a deleted answer. Anyway, I’ll try to avoid it in the future. Usually I just copy all the text of my post before hitting submit so I can paste it back in if my browser crashes. $\endgroup$ Jul 26, 2017 at 0:29
  • $\begingroup$ @quid Regarding time, the first sentence of my edit was: “You’re right that in theory steps 1, 2, and 5 take little time.” I don’t know the number of seconds or minutes I spend on each part, but I invite you to try it yourself if you are so-inclined. I certainly think the bulk of the time is spent creating the image, but the cropping and resizing is not trivial, either. $\endgroup$ Jul 26, 2017 at 0:29
  • $\begingroup$ @AsafKaragila The entire point of this longer list is that while in theory the process may be simple, in practice there are many little hiccups and time-sinks that can occur, many of which would not be apparent to someone who has not tried to do it themselves. So Asaf, when was the last time you made an image in TikZ and included it on a post in Stack Exchange? These are problems I have run into myself while creating some of these graphics. $\endgroup$ Jul 26, 2017 at 0:30
  • $\begingroup$ Oh, I'm still fighting the WW2 generals ghosts for posting my first one. $\endgroup$
    – Asaf Karagila Mod
    Jul 26, 2017 at 5:32
  • $\begingroup$ Well, as long as I do not know at all how long it takes you roughly to create such an image to check how long it takes to open a file will not tell much about the relative time needed. I will admit though that actually that sentence did not fully register; otherwise I would phrased my comment differently. Sorry about that. Yet I truly have little idea how long it takes to create (you) the image, as I do not do this myself with any regularity. All that said, I still feel that you have some illusions how smoothly it would work if the thing would be integrated on the site. $\endgroup$
    – quid Mod
    Jul 26, 2017 at 8:15
  • $\begingroup$ For one thing, at times you would I assume still want to start on an existing image. So rather than to search the file locally you would (a) search it among your posts here, which may or may not be simpler. Then you would need to transfer it. So you would need to (b) click edit on the old post, to (c) copy the source I assume. Then you need to (d) go back to the new post and (e) insert it. There you might forget (d) and rather (d') actually start to edit the old post (d'') realize your mistake in the worst case (d''') roll back the old post (d'''') apologize for having created a mess. $\endgroup$
    – quid Mod
    Jul 26, 2017 at 8:22
  • $\begingroup$ Then (f) actually create the image, (g) check it looks good in the preview (h) change it as it does not lock good in the preview, then sometimes maybe (i) realize the preview stopped working (j) copy out or save the source (k) refresh the page or restart the browser (l) continue with the editing etc. More seriously, I can imagine some advantages to it being integrated here, but that it would work that smoothly in comparison to doing it locally seems like wishful thinking to me. $\endgroup$
    – quid Mod
    Jul 26, 2017 at 8:28
  • 2
    $\begingroup$ @quid: You forgot to mention the neuron firing to pass information to the muscles to move the hand, the fingers, and so on, between each of the steps. These take time too, ya'know! $\endgroup$
    – Asaf Karagila Mod
    Jul 26, 2017 at 10:11
  • $\begingroup$ @quid I think we’ve misunderstood each other. The reason I start with an existing file is so that I get the preamble with all the packages I usually need. I typically delete all the markup for the image and start from scratch. I always do with this when I make a new LaTeX file, regardless of whether or not I use TikZ. But I have no need to look through my old posts when I write a new post, and I wouldn’t have to for making new images either, since presumably most of these packages would automatically be included, just like they are for regular LaTeX. $\endgroup$ Jul 26, 2017 at 21:08
  • 1
    $\begingroup$ Indeed, I have misunderstood this. In this case maybe just put one sample file on the desktop? Also, why is 3 a problem if you never reuse the files anyway? Alright I am not quite serious in continuing this, and got a bit carried away. :-) I think I'll just stand by: "I can imagine some advantages to it being integrated here, but that it would work that smoothly in comparison to doing it locally seems like wishful thinking to me" Thank you, for compiling the list of posts; it makes a good basis for the discussion. $\endgroup$
    – quid Mod
    Jul 26, 2017 at 23:44
2
$\begingroup$

One concern I have over implementing this feature is exactly how it would be set up on the site vis-à-vis comments. By intention comments on Stack Exchange sites allow only a very limited subset of Markdown markup (italics, bold, italic bold, inline code, and links). However a side effect of the way MathJax is set up on MathJax-enabled Stack Exchange sites is that comments on these sites also "allow" MathJax. This may often be useful, but at times we get very MathJax-laden comments with numerous displayed equations which end up looking more like (mini-)posts than how comments were intended. For example (some details changed to protect the innocent):

comment or post?

As it is, I am mainly "meh" about this feature request: it might be something nice to have, but I feel it will be of only very limited utility on the site compared to the overhead required. But TikZ-laden comments make me nervous, and this is something I decidedly do not wish to see on the site. Unless this could be implemented in a way so that TikZ does not render in comments, I would be against implementing such a feature.

$\endgroup$
1
  • 1
    $\begingroup$ I guess that one way to ensure that is to make the TiKZ code wrapper about 500 characters long, and this way you only have 100 characters for the actual content, which won't be too much, I hope. :P $\endgroup$
    – Asaf Karagila Mod
    Jul 25, 2017 at 6:55

You must log in to answer this question.

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