TikZJax not rendering #3069
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Pluto allows js to modify all content, but i suspect that tikzjax is only designed to convert scripts into diagrams once, during page load, and not when added dynamically like you are doing. Check out the featured notebooks about JavaScript to learn more about how to debug this. You can also tell Pluto to render your cell in an iframe: put an tag around the content. |
Beta Was this translation helpful? Give feedback.
-
Ok, so after some more research and tinkering I've come upon a much better way to integrate Tikz into Pluto.jl. Though it does require a working lualatex in your path to run. TikzPictures.jl already exists and integrates with IJulia but doesn't quite work out of the box for Pluto.jl and also has almost no documentation so here's my solution. Thankfully Pluto.jl does simply display the output of TikzPictures.jl but simple Tikz doesn't really work in dark mode and TikzPictures.jl has a rather cumbersome syntax for adding extra packages, using different environments and options. My solution goes as follows: begin
using TikzPictures
macro tikz_str(input, width=20)
preamble, environment, options, input = split(input, ';', limit=4)
environment == "" && (environment = "tikzpicture")
TikzPicture(input,
preamble="\\usetikzlibrary{backgrounds} $preamble",
options="$options , background rectangle/.style={fill=white!45}, show background rectangle",
width="$(width)cm")
end
end Which allows one to insert tikz into Pluto.jl with a little extra syntax at the top tikz"""
\usepackage{circuitikz}
;
circuitikz
;
american voltages
;
\draw
(0,0) to [short, *-] (6,0)
to [V, l_=$\mathrm{j}{\omega}_m \underline{\psi}^s_R$] (6,2)
to [R, l_=$R_R$] (6,4)
to [short, i_=$\underline{i}^s_R$] (5,4)
(0,0) to [open, v^>=$\underline{u}^s_s$] (0,4)
to [short, *- ,i=$\underline{i}^s_s$] (1,4)
to [R, l=$R_s$] (3,4)
to [L, l=$L_{\sigma}$] (5,4)
to [short, i_=$\underline{i}^s_M$] (5,3)
to [L, l_=$L_M$] (5,0);
""" Something like this, in my opinion, completes Pluto.jl's scientific feature set. Making a good diagram is often absolutely necessary. I understand not having support for arbitrary LaTeX, but support for some of the most common tikz packages would be wonderful. |
Beta Was this translation helpful? Give feedback.
Thanks! That seems to work! I threw together a macro as a proof of concept.