Does This Forum Support TikZ Rendering?

  • Thread starter karush
  • Start date
In summary: Instead it could be a custom solution where a section with TikZ code is converted to an html <img> element with the TikZ code as url-parameter that is requested from a dedicated server.It would not impact the resource load time of regular pages, and the pages with TikZ will just load the image as intended without any overhead. The images could be in SVGZ format (compressed scaled vector graphics
  • #1
karush
Gold Member
MHB
3,269
5
Summary: want to post tikz here

ok I really didn't know where to post this but can this forum render tikz
I saw some other examples but don't know the setup here

$\begin{tikzpicture}
\draw[->] (-3,0) -- (4.2,0) node
{$x$};
\draw[->] (0,-3) -- (0,4.2) node[above] {$y$};
\draw[dashed] (-3,-3) -- (4,4);
\draw[scale=0.5,domain=-3:3,smooth,variable=\x,blue] plot ({\x},{\x*\x});
\draw[scale=0.5,domain=-3:3,smooth,variable=\y,red] plot ({\y*\y},{\y});
\draw[scale=0.5,domain=-3:3,smooth,variable=\y,green] plot ({\x},{sqrt(\x)});
\end{tikzpicture}$​
 
  • Like
Likes Filip Larsen and I like Serena
Physics news on Phys.org
  • #2
karush said:
Summary: want to post tikz here

ok I really didn't know where to post this but can this forum render tikz
I saw some other examples but don't know the setup here

$\begin{tikzpicture}
\draw[->] (-3,0) -- (4.2,0) node
{$x$};
\draw[->] (0,-3) -- (0,4.2) node[above] {$y$};
\draw[dashed] (-3,-3) -- (4,4);
\draw[scale=0.5,domain=-3:3,smooth,variable=\x,blue] plot ({\x},{\x*\x});
\draw[scale=0.5,domain=-3:3,smooth,variable=\y,red] plot ({\y*\y},{\y});
\draw[scale=0.5,domain=-3:3,smooth,variable=\y,green] plot ({\x},{sqrt(\x)});
\end{tikzpicture}$​

You need double $ to enter LaTeX. However, this is the result:
1662791040925.png
 
  • #3
karush said:
can this forum render tikz
Most probably no. I know MHB could, but in PF, we haven't needed Tikz till date.

Test:
$$\require{tikz}
\begin{tikzpicture}
\draw[->] (-3,0) -- (4.2,0) node
{$x$};
\draw[->] (0,-3) -- (0,4.2) node[above] {$y$};
\draw[dashed] (-3,-3) -- (4,4);
\draw[scale=0.5,domain=-3:3,smooth,variable=\x,blue] plot ({\x},{\x*\x});
\draw[scale=0.5,domain=-3:3,smooth,variable=\y,red] plot ({\y*\y},{\y});
\draw[scale=0.5,domain=-3:3,smooth,variable=\y,green] plot ({\x},{sqrt(\x)});
\end{tikzpicture}$$
 
  • #5
Greg Bernhardt said:
Tikz has not been installed, I'm still mulling it over
I guess installing Tikz will significantly increase the size of the MathJax resource that has to be loaded. Maybe users can render the diagram somewhere else (like Overleaf with the standalone package) and post the rendered diagram as an image.
 
  • Like
Likes Greg Bernhardt
  • #6
Wrichik Basu said:
I guess installing Tikz will significantly increase the size of the MathJax resource that has to be loaded. Maybe users can render the diagram somewhere else (like Overleaf with the standalone package) and post the rendered diagram as an image.
MathJax does not support TikZ.

Instead it could be a custom solution where a section with TikZ code is converted to an html <img> element with the TikZ code as url-parameter that is requested from a dedicated server.

It would not impact the resource load time of regular pages, and the pages with TikZ will just load the image as intended without any overhead. The images could be in SVGZ format (compressed scaled vector graphics) and as such be much smaller than a copy-and-pasted picture would be.

Separately, it is possible to have a dedicated online TikZ editor where you can interactively create pictures on the fly while typing (somewhat similar to Overleaf), and then either copy and paste the TikZ code in a post, or alternatively copy-and-paste the resulting picture into a post.
 
Last edited:
  • #7
Windows 10: if you can render the image on your computer, press windows-shift-S, mark the area you are interested in, then just ctrl-V the image into the edit field (doesn't work in UBBC mode though).

You'll get something like this (actually a random piece of what I am seeing on my screen now):

1662842591587.png
 
  • #8
Greg Bernhardt said:
Tikz has not been installed, I'm still mulling it over
My votes against:
  • Science Advisors (and I'm sure Mentors too) spend a great deal of time correcting people's mistakes in LaTeX; I for one would not be keen on doing the same in Tikz.
  • Once you have implemented Tikz there is no going back - if it becomes unsupported then PF is broken.
  • The in-browser implementation of Tikz is a remarkable achievement, or from another perspective it is the most almighty hack - at its heart (I think) is an on-the-fly Pascal compiler written in JavaScript targeting WebAssembly to compile TeX on-the-fly and then run it on the input, post-processing the DVI output into SVG! This is pretty demanding on the users hardware.
  • The workaround for "lack of Tikz" is already implemented: compose an image using an appropriate tool for the purpose and upload it.
  • There are plenty of other things we might want to support for graphing and diagrams: Plotly? Graphviz? How do we choose? Where do we stop?
 
Last edited:
  • Like
Likes DrClaude, dextercioby, Wrichik Basu and 2 others
  • #9
pbuk said:
My votes against:
  • Science Advisors (and I'm sure Mentors too) spend a great deal of time correcting people's mistakes in ## \LaTeX ##; I for one would not be keen on doing the same in Tikz.
People often can't be bothered to write formulas properly in LaTeX, which tends to land on mentors. It's different for TikZ. Regular visitors won't use it. It's the people who respond to posts who "might" use it, and then only if they are proficient in it. So I don't think this is a valid argument.
pbuk said:
  • Once you have implemented Tikz there is no going back - if it becomes unsupported then PF is broken.
If TikZ is no longer supported in-browser, then the "unsupported tikzpicture environment" remains behind, which is the case in a number of MHB posts now. Not really fatal.
The alternative is to merely have a helpful online editor, and still copy-and-paste it as pictures into posts. Then it can't be broken. This could be a first step to see if people here like it before making PF dependent on it.
pbuk said:
  • The in-browser implementation of Tikz is a remarkable achievement, or from another perspective it is the most almighty hack - at its heart (I think) is an on-the-fly Pascal compiler written in JavaScript targeting WebAssembly to compile ## \TeX ## on-the-fly and then run it on the input, post-processing the DVI output into SVG! This is pretty demanding on the users hardware.
Not sure what you are saying here. Input is standardized LaTeX. Output is a picture that any browser supports. The user's hardware is not impacted by it - at all. It does mean there is a server that is processing the pictures.
pbuk said:
  • The workaround for "lack of Tikz" is already implemented: compose an image using an appropriate tool for the purpose and upload it.
As said, as a first step it is possible to just facilitate exactly that. We might make it easier for people to create pictures using latex, and still insert them as regular pictures.
pbuk said:
  • There are plenty of other things we might want to support for graphing and diagrams: Plotly? Graphviz? How do we choose? Where do we stop?
We don't support Microsoft's Equation editor either, nor any other formula typesetters. What we do support is the standardized method to write math formulas, which is LaTeX. TikZ is "just" LaTeX. It's just that MathJax does not support it.
 
Last edited:
  • Like
Likes fluidistic
  • #10
I like Serena said:
Not sure what you are saying here. Input is standardized LaTeX. Output is a picture that any browser supports. The user's hardware is not impacted by it - at all. It does mean there is a server that is processing the pictures.
I was referring to TikZJax which runs in the browser (and I assume was the implementation used by MHB).
I like Serena said:
As said, as a first step it is possible to just facilitate exactly that. We might make it easier for people to latex to create pictures using latex, and still insert them as regular pictures.
Oh doesn't that exist already - I thought there was a pastebin for TikZ code somewhere?
 
  • #11
pbuk said:
This is pretty demanding on the users hardware.
How well does it work on phones?
 
  • #12
pbuk said:
I was referring to TikZJax which runs in the browser (and I assume was the implementation used by MHB).
No. MHB did not use that. MHB had a dedicated server that converted TikZ code to pictures on the fly.
 
  • Wow
  • Like
Likes mfb and pbuk
  • #13
Vanadium 50 said:
How well does it work on phones?
The TikZ that we had on MHB worked correctly on a phone without impact on performance.
 
  • #14
I like Serena said:
No. MHB did not use that. MHB had a dedicated server that converted TikZ code to pictures on the fly.
Wow, interesting choice.
 
  • #15
Vanadium 50 said:
How well does it work on phones?
Go to https://tikzjax.com/ and see (about 2s to render a simple circle on my Samsung A52).
 
  • Like
  • Informative
Likes topsquark and I like Serena
  • #16
pbuk said:
Go to https://tikzjax.com/ and see (about 2s to render a simple circle on my Samsung A52).
Interesting. I was not aware of tikzjax yet.

I gave it a shot, and tried a more complicated figure.

1662852700278.png

It works out of the box, so that is good.
Unfortunately it doesn't seem to support the "blend group".

More seriously, it does not look as if we would be able to use it "as is".
If there is a mistake in the TikZ, or something that is not supported, it breaks the page, and nothing gets rendered afterwards. The logging contains:
1662852868669.png

And that is for something that is actually valid TikZ.

From a security perspective I think it also has a problem, since each TikZ picture is supposed to be wrapped in <-s-c-r-i-p-t-> tags, which is not something we want to expose to end users.
EDIT: I can't even write that tag here without Cloudflare complaining about it. Even with spaces between the letters it won't allow it.
 
Last edited:
  • #17
  • Informative
Likes I like Serena
  • #18
Can I upload SVG to PF?

Numeral 9 pennant
 
  • Informative
Likes I like Serena
  • #19
So editing works OK at https://pb-uk.github.io/tikzbin/ and you can save a file OK, but PF won't upload SVG files, they have to be served from somewhere else (for a very good reason I should have thought about).

We could convert SVG to PNG in the browser but @I like Serena do you think it is worth persuing a TikZJax based solution or is there not enough of TikZ implemented in there to make it worthwhile?
 
  • Like
Likes Vanadium 50
  • #20
pbuk said:
So editing works OK at https://pb-uk.github.io/tikzbin/ and you can save a file OK, but PF won't upload SVG files, they have to be served from somewhere else (for a very good reason I should have thought about).
For what reason shouldn't PF support the upload of SVG files?

As you have just shown, PF already supports SVG files directly through the use of [IMG] tags. But uploading is apparently limited.

pbuk said:
We could convert SVG to PNG in the browser but @I like Serena do you think it is worth persuing a TikZJax based solution or is there not enough of TikZ implemented in there to make it worthwhile?
I tried a couple of the pictures we had on MHB, but most of them don't work. It seems only the most basic pictures work correctly. More advanced stuff either doesn't work at all, or gives results that are different from what they should be.

On MHB we had a similar TikZ live editor that did support all of TikZ. It regenerated the picture continuously while typing, and it provided templates for typical pictures you might want to use on a math/physics site.
 
  • #21
I like Serena said:
For what reason shouldn't PF support the upload of SVG files?
It is possible to embed a malicious script in an SVG file which potentially exposes the user's session credentials on the server hosting the image.

I like Serena said:
I tried a couple of the pictures we had on MHB, but most of them don't work. It seems only the most basic pictures work correctly. More advanced stuff either doesn't work at all, or gives results that are different from what they should be.
In that case there doesn't seem to me to be much point in using TikZJax.
 
  • #22
pbuk said:
It is possible to embed a malicious script in an SVG file which potentially exposes the user's session credentials on the server hosting the image.
New to me. Ah well. If the SVG picture comes from a dedicated server where it is generated from TikZ code, that shouldn't be a problem.
If the SVG picture is copied and pasted from elsewhere, including an online TikZ editor, I guess that may still be a problem. In that case a live TikZ editor should provide a PNG image (or similar) instead of an SVG image, which is implicitly already the case since currently SVG can't be uploaded to PF.

pbuk said:
In that case there doesn't seem to me to be much point in using TikZJax.
It seems as if tikzjax is still in its infancy. Eventually it may go somewhere, but I think it's not there yet.
MHB had integrated TikZ images since 2016 and the live editor was added in 2017.

As I understand it, @Greg Bernhardt is still mulling over whether to add the live editor to PF (without TikZ integration in PF posts). I guess it depends on whether people here would be interested in it.
 
Last edited:
  • #23
I like Serena said:
It seems as if tikzjax is still in its infancy. Eventually it may go somewhere, but I think it's not there yet.
It looks abandoned - no changes to the code for 4 years.

I like Serena said:
As I understand it, @Greg Bernhardt is still mulling over whether to add the live editor to PF (without TikZ integration in PF posts). I guess it depends on whether people here would be interested in it.
Personally I would rather use Overleaf e.g.
1662978116439.png

Source: https://www.overleaf.com/read/sqsvfwwfdgdg
 

Attachments

  • Screenshot 2022-09-12 at 11-08-05 Venn Diagram.png
    Screenshot 2022-09-12 at 11-08-05 Venn Diagram.png
    5.8 KB · Views: 131
  • #24
I don't understand the request. Just take a screen shot of the image you want and paste it into a PF post. Other than resolution, what advantage is there to edit on PF, or upload image files to PF?
 
  • Like
Likes Wrichik Basu
  • #25
anorlunda said:
Just take a screen shot of the image you want and paste it into a PF post.
That assumes that you have some way of creating the image you want on the screen of whatever device you are using. Pasting a screenshot is essentially the same as uploading an image.

anorlunda said:
Other than resolution, what advantage is there to edit on PF, or upload image files to PF?
  • You can only insert or upload a raster image: SVG (vector) images (which would need to be generated from a trusted source) have a number of advantages.
  • Unless you have access to the source you cannot edit an image produced by someone else.
 
  • Like
Likes I like Serena
  • #26
In case TikZ gets installed, MHB threads would fix automatically.
In case TikZ installation is not considered, existing TikZ code can be rendered elsewhere and replaced here with rendered images (either manually or preferably via a script).
 
  • Like
Likes I like Serena
  • #27
We could also write math formulas in some other program and copy-and-paste them here. That's how it used to work. At the time PF came with an innovation so that latex formulas were rendered automatically as raster images (yes, I'm old enough to remember that). It was eventually replaced by MathJax. I can't really imagine the site without MathJax integration anymore. If MathJax was no longer available and if all formulas were replaced by raster images, I think the site would just die for using outdated technology.

TikZ is a similar innovation. Of course we can create pictures with external tools as well and copy-and-paste them. But a nice integration is cool, pretty, and makes it easier for ourselves and for others.
 
Last edited:
  • Love
  • Like
Likes karush and S.G. Janssens
  • #28
where is a good tikz forum

ok from reading posts it seems that tikz code would come from users already proficient with it and then a rendered code from another program would upload a an image on PH, When MHB existed I got very valuable help on writing tikz code. And currently find it hard to find help. Exchange has some great sources of advice however my experience with them is the few times I try to post I get hit with protocol so hopefully an example will show up.. Im sure most users are fine with Desmos then screenshot and crop to upload to PH. However, for example with ticks mostly only a few are needed for a graph but Desmos is the the full set.... Any math problem is basically has a graph representation and I think Tikz would just be a great asset, I understand the learning code curve is a little steep but using latex in forums was also kind of steep if one only knew pencil and paper... my take anyway
 

FAQ: Does This Forum Support TikZ Rendering?

Can TikZ render graphics in any document format?

Yes, TikZ can render graphics in various document formats such as PDF, SVG, and PostScript. It can also be integrated with LaTeX, ConTeXt, and plain TeX documents.

Is TikZ compatible with all operating systems?

Yes, TikZ is compatible with all operating systems including Windows, Mac OS, and Linux.

Can TikZ be used for 3D graphics?

Yes, TikZ has the ability to create 3D graphics using the TikZ-3dplot package. However, it is not as powerful as dedicated 3D graphics software.

Are there any limitations to the complexity of graphics that TikZ can render?

TikZ can handle complex graphics, but it may become slow and cumbersome for very large and intricate designs. In such cases, it is recommended to use specialized software.

Can TikZ be used for animations?

Yes, TikZ can be used to create simple animations by changing the properties of objects over time. However, it is not designed for complex animations and may not be the most efficient tool for this purpose.

Similar threads

Back
Top