# [SOLVED]Render latex drawings?

#### Klaas van Aarsen

##### MHB Seeker
Staff member
I just saw this post with a latex description of a picture in tikzpicture format.
It was followed (on request ) by the rendering in this post.
It looked nice!
I wish I could do that.

Then I wondered... would it be possible to get a latex plug-in that can render it?

#### Evgeny.Makarov

##### Well-known member
MHB Math Scholar
Then I wondered... would it be possible to get a latex plug-in that can render it?
Yes, it is possible. You can download TikZ 2.10 here. You can find the PDF manual here. It has 726 pages! Installation is described in Part II. I personally don't have TeX under Windows, but the manual says: "For MiKTEX, use the update wizard to install the (latest versions of the) packages called pgf and xcolor." In Ubuntu, you can install the package pgf. Then the LaTeX file is

Code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
% Picture code from dwsmith's post
\end{document}
Edit: Oops, apparently I misunderstood the question. If it refers to the plugin for the forum, then I don't know.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Sorry for the confusion.
But yes, I meant a plug-in for the forum.
Right now it's still a bit of a hassle to get a simple drawing in.

(And I found I can only upload 195 KB worth of attachments. I already had to turn up compression to get my picture accepted. )

#### Chris L T521

##### Well-known member
Staff member
I just saw this post with a latex description of a picture in tikzpicture format.
It was followed (on request ) by the rendering in this post.
It looked nice!
I wish I could do that.

Then I wondered... would it be possible to get a latex plug-in that can render it?
I like this idea. If there isn't a plug-in out there that does such a thing, I'll take time to create one for us. I'm going to be around more often now that things have settled down a bit for me, so I'll see what I can do about this. Don't expect anything soon, though, since I'm currently working on other projects for the site right now.

#### Jameson

Staff member
I think I've found a way we can offer some kind of functionality to render graphics through Latex. This software, XyJax, is apparently compatible with Mathjax right out of the box. I need to ask about one detail and I'll try installing it. Right now we don't host the javascript file for Mathjax on our server to because they offer this service for free and it might slow down MHB if used a lot at once. The graphics package I mentioned above though only mentions installing it with all files on your own server, so no promises yet but I really hope we can try it out.

#### Chris L T521

##### Well-known member
Staff member
I think I've found a way we can offer some kind of functionality to render graphics through Latex. This software, XyJax, is apparently compatible with Mathjax right out of the box. I need to ask about one detail and I'll try installing it. Right now we don't host the javascript file for Mathjax on our server to because they offer this service for free and it might slow down MHB if used a lot at once. The graphics package I mentioned above though only mentions installing it with all files on your own server, so no promises yet but I really hope we can try it out.
I like this, but I must say that the syntax is pretty interesting. It would be a nice thing to have (at least for now) if the trying out phase is a success.

Aside:
I'm still going to work on a tikz plug-in as a side project; as my housemate (who does computer engineering) said, I'm going to be a maestro of javascript when I complete this tikz project (we projected that if I spend a couple hours a week on it, I should be done in a few months; given my current state of things with prelims and such, I'd say you should see some results of my work on this sometime in September). So far, my idea is to use the javascript graphics library and find a way to translate tikz syntax into javascript syntax...and a bunch of other things that I don't really want to think about. Again, this won't be done for many months, but for the time being, I'm going to be experimenting with javascript and really see if this is the way I should be approaching this.

#### Jameson

Staff member
Good point about the syntax. I'll have to see if it's worth making everyone learn.

Your project sounds like it would be fun to experiment with but there are already multiple ways to generate graphics using Latex online. AoPS uses LatexRender for rendering images and while Mathjax is much clearer they aren't limited to certain packages like we are. We could actually run both and just use LatexRender for graphics. AoPS also have other packages running on their site that will generate amazing graphics. I'm sure with a small bit of research we can figure out how to do the same.

So it'd be really cool to know you wrote a functioning plug-in for Tikz but in the meantime there seem to be lots of options we can and should be using.

#### Chris L T521

##### Well-known member
Staff member
Good point about the syntax. I'll have to see if it's worth making everyone learn.

Your project sounds like it would be fun to experiment with but there are already multiple ways to generate graphics using Latex online. AoPS uses LatexRender for rendering images and while Mathjax is much clearer they aren't limited to certain packages like we are. We could actually run both and just use LatexRender for graphics. AoPS also have other packages running on their site that will generate amazing graphics. I'm sure with a small bit of research we can figure out how to do the same.

So it'd be really cool to know you wrote a functioning plug-in for Tikz but in the meantime there seem to be lots of options we can and should be using.
Of course, in the meantime you should certainly go with something like that (this is the first that I'm hearing of LaTeXRender, so I'll look into that on my own). Just to be clear, I wasn't suggesting that you should wait for me to be done with my awesome project.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
I just looked at XyJax.
But to be honest, I don't like it much.
Its syntax looks very unintuitive.
And I do not see examples of cool and easy-to-do pictures.

#### Jameson

Staff member
Fair enough and I agree that there are easier to code software available for free. I found a handful of choices yesterday after discovering XyJax. If they don't run off of Mathjax then we'll have to do a good amount of software installation and need to consider how much bandwidth this could potentially use.

For most basic 2d graphs I highly recommend our friends at desmos.com and with their help it's super easy now to post any graph here from their site or calculator. If having more advanced image rendering functionality can make it truly more convenient to post here, then that's one thing but there is some point where it's just trying to show off

I am not an expert with Latex packages and especially not with knowing what's best to use on a local server with a finite bandwidth limit. AoPS lists all of the software they use, which sounds promising, but they don't go into how they install something like Asymptote, an interesting looking graphing utility. So although there are many options, this is a topic to be careful with. If anyone has any experience with using Latex packages and graphics on a live website please let me know. I'll be reading whatever I can find in the meantime.

#### dwsmith

##### Well-known member
Fair enough and I agree that there are easier to code software available for free. I found a handful of choices yesterday after discovering XyJax. If they don't run off of Mathjax then we'll have to do a good amount of software installation and need to consider how much bandwidth this could potentially use.

For most basic 2d graphs I highly recommend our friends at desmos.com and with their help it's super easy now to post any graph here from their site or calculator. If having more advanced image rendering functionality can make it truly more convenient to post here, then that's one thing but there is some point where it's just trying to show off

I am not an expert with Latex packages and especially not with knowing what's best to use on a local server with a finite bandwidth limit. AoPS lists all of the software they use, which sounds promising, but they don't go into how they install something like Asymptote, an interesting looking graphing utility. So although there are many options, this is a topic to be careful with. If anyone has any experience with using Latex packages and graphics on a live website please let me know. I'll be reading whatever I can find in the meantime.
What is wrong with using tikz?

#### Jameson

Staff member
What is wrong with using tikz?
Nothing. I just don't know if that's going to suit us well or not well. There is a lot of free and open source software to use but still installing everything isn't simple I'm nervous to just put something on our server that dynamically generates images without knowing how secure or resource heavy it will be.

#### dwsmith

##### Well-known member
Nothing. I just don't know if that's going to suit us well or not well. There is a lot of free and open source software to use but still installing everything isn't simple I'm nervous to just put something on our server that dynamically generates images without knowing how secure or resource heavy it will be.
There probably aren't too many people who would take use it enough to bog down the system. I can only think of a handful of people here that would probably use it. But it makes generating images for questions remarkable easier. Also, when someone asks a question that requires a picture, we could just code it up on the site instead of make the image, upload to imageshack, and then put it on the site. Taking 3 steps down to one.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Yes, it is possible. You can download TikZ 2.10 here. You can find the PDF manual here. It has 726 pages! Installation is described in Part II. I personally don't have TeX under Windows, but the manual says: "For MiKTEX, use the update wizard to install the (latest versions of the) packages called pgf and xcolor." In Ubuntu, you can install the package pgf. Then the LaTeX file is

Code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
% Picture code from dwsmith's post
\end{document}
Edit: Oops, apparently I misunderstood the question. If it refers to the plugin for the forum, then I don't know.
I took the time to install MikTEX in Windows.
Turns out that dwsmith's post together with your document wrapper worked right of the bat.
MikTEX automatically downloaded tikz including its manual, when I tried to render it.
I've started making tikz drawings, which I'm copying+pasting for now.
You can expect more elaborate drawings from me in the time to come!

(Copying+pasting is just until it's supported natively. )

#### dwsmith

##### Well-known member
I took the time to install MikTEX in Windows.
Turns out that dwsmith's post together with your document wrapper worked right of the bat.
MikTEX automatically downloaded tikz including its manual, when I tried to render it.
I've started making tikz drawings, which I'm copying+pasting for now.
You can expect more elaborate drawings from me in the time to come!

(Copying+pasting is just until it's supported natively. )
Here is something a little more complicated to look at
Code:
\begin{center}
\begin{tikzpicture}[dot/.style = {circle, inner sep = .07cm, fill,label = {#1}, name = #1}, extended line/.style = {shorten >=-#1, shorten <=-#1}, extended line/.default = 1cm, one end extended/.style = {shorten >=-#1}, one end extended/.default = 1.25cm, line cap = round, line join = round, >=triangle 45]
\draw (0,-3.25) -- (0,3.25) node[scale = .8, fill = white] at (0,1.25) {$b$};
\draw[red] (0,0) circle (3cm);
\begin{scope}
\clip (2.59808,1.5) -- (2.59808,0) -- (3,0) -- (3,1.5) -- cycle;
\shadedraw[blue, top color = green!50!black, bottom color = blue!30] (0,0) ellipse (3cm and 2.5cm);
\end{scope}
\draw[blue, name path = ellipse 1] (0,0) ellipse (3cm and 2.5cm);
\draw[name path = line 1] (2.59808,1.5) -- (2.59808,0);
\path[name intersections = {of = line 1 and ellipse 1, by = S}];
\node[fill, circle, inner sep = .07cm, label = 0:$S$, scale = .8] at (S) {};
\draw[one end extended] (1.75,0) -- (S);
\begin{scope}
\clip (2.59808,1.5) -- (2.59808,0) -- (-2,0) -- (-2,1.5) -- cycle;
\shadedraw[bottom color = cyan!50!blue, top color = green!20, one end extended] (1.75,0) -- (S) -- (2.59808,0) -- (1.75,0) -- cycle;
\end{scope}
\draw[one end extended] (1.75,0) -- (S);
\draw (2.59808,1.5) -- (2.59808,0);
\draw (-3.25,0) -- (5,0) node[scale = .8, fill = white] at (-1.625,0) {$a$};
\draw (0,0) -- (2.59808,1.5) node[scale = .8, fill = white] at (1.29904,0.75) {$a$};
\filldraw (-3,0) circle (.07cm) node[scale = .8] at (-3.2,-0.25) {$A$};
\filldraw (3,0) circle (.07cm) node[scale = .8] at (3.2,-0.25) {$P$};
\filldraw (0,-2.5) circle (.07cm) node[scale = .8] at (-0.25,-2.7) {$D$};
\filldraw (0,2.5) circle (.07cm) node[scale = .8] at (-0.25,2.7) {$B$};
\filldraw (1.75,0) circle (.07cm) node[scale = .8] at (1.5,-0.25) {$F$};
\filldraw (2.59808,1.5) circle (.07cm) node[scale = .8, fill = white, inner sep = .05cm] at (2.84808,1.75) {$Q$};
\filldraw (0,0) circle (.07cm) node[scale = .8] at (-0.25,-0.25) {$O$};
\filldraw (2.59808,0) circle (.07cm) node[scale = .8] at (2.34808,-0.25) {$V$};
\filldraw[inner color = pink!70!, outer color = blue!40!black] (0,0) -- (0.875,0) arc (0:30:0.875cm);
\node[scale = .8, fill = white, inner sep = .04cm, circle] at (1,0) {$ae$};
\node[scale = .8] at (1,0.28) {$E$};
\node[scale = .8, fill = white, inner sep = .07cm] at (2.2,.63) {$r$};
\draw[->] (4,0) arc (0:43:3cm) node[scale = .8, fill = white, inner sep = .07cm] at (15:4cm) {$\nu$};
\end{tikzpicture}
- - - Updated - - -

Here is something in 3D
Code:
\tdplotsetmaincoords{72}{120}
\begin{tikzpicture}[line join = round, line cap = round, >=triangle 45, tdplot_main_coords]
\draw[->] (0,0,0) -- (0,5,0) node[right, scale = .75] {$y$};
\draw[->] (0,0,0) -- (0,0,5) node[above, scale = .75] {$z$};
\draw[dashed] (-3,0,0) -- (0,0,0);
\draw[->] (0,0,0) -- (6,0,0) node[below, scale = .75] {$x$};
\shadedraw[opacity = .5] (-3,0,0) circle (.22cm);
\shadedraw[opacity = .6] (4,0,0) circle (.3cm);
\shadedraw[blue, opacity = .8] (3,4,5) circle (.1cm);
\draw[dashed] (3,4,4.9) -- (3,4,0);
\draw[dashed] (3,4,0) -- (3,0,0);
\draw[dashed] (3,4,0) -- (0,4,0);
\draw[dashed] (-3,0,0) -- (-3,-3,0);
\draw[dashed] (4,0,0) -- (4,-3,0);
\draw[<->] (4,-2,0) -- (-3,-2,0) node[scale = .75, fill = white] at (0.5,-2,0) {$r_{12}$};
\draw[->] (4,0,0) -- (3,4,5) node[scale = .75, fill = white] at (3.5,2,2.5) {$\mathbf{r}_2$};
\draw[->] (-3,0,0) -- (3,4,5) node[scale = .75, fill = white] at (0,2,2.5) {$\mathbf{r}_1$};
\draw[->] (0,0,0) -- (3,4,5) node[scale = .75, fill = white] at (1.5,2,2.5) {$\mathbf{r}$};
\node[right, scale = .75] at (-3,-.2,-0.5) {$m_1$} node[scale = .75, fill = white] at (-3,1,0.15) {$(x_1,0,0)$};
\node[scale = .75] at (3,4,5.25) {$m$} node[scale = .75] at (3,4.75,5.15) {$(x,y,z)$};
\node[right, scale = .75] at (4,0.35,0) {$m_2$} node[scale = .75] at (4.25,0.15,-0.5) {$(x_2,0,0)$};
\end{tikzpicture}

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Code:
! Package pgfkeys Error: I do not know the key '/tikz/name path' and I am going
to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
...

l.14 \draw[blue, name path = ellipse 1]
(0,0) ellipse (3cm and 2.5cm);
?

#### dwsmith

##### Well-known member
Code:
! Package pgfkeys Error: I do not know the key '/tikz/name path' and I am going
to ignore it. Perhaps you misspelled it.

See the pgfkeys package documentation for explanation.
Type  H <return>  for immediate help.
...

l.14 \draw[blue, name path = ellipse 1]
(0,0) ellipse (3cm and 2.5cm);
?
Code:
\usepackage{tikz, tikz-qtree,  mathtools, pgfplots, tikz-3dplot, tkz-fct}
\usetikzlibrary{arrows,decorations.markings,calc,fadings,decorations.pathreplacing, patterns, decorations.pathmorphing, positioning}

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Code:
\usepackage{tikz, tikz-qtree,  mathtools, pgfplots, tikz-3dplot, tkz-fct}
\usetikzlibrary{arrows,decorations.markings,calc,fadings,decorations.pathreplacing, patterns, decorations.pathmorphing, positioning}
The 3D picture works, but the first picture still gives the same error.

#### dwsmith

##### Well-known member
The 3D picture works, but the first picture still gives the same error.

Do you have all those packages installed? If on windows, go to start and find miktex, you should see an admin package manager. There you can download what you need.

#### Klaas van Aarsen

##### MHB Seeker
Staff member
Do you have all those packages installed? If on windows, go to start and find miktex, you should see an admin package manager. There you can download what you need.
Yes, I got all the packages.
After googling on the error, I found that I needed an additional
Code:
\usetikzlibrary{intersections}

#### dwsmith

##### Well-known member
Yes, I got all the packages.
After googling on the error, I found that I needed an additional
Code:
\usetikzlibrary{intersections}

If you can understand everything going on in those pictures, you should be able to do more than copy and paste afterwards.