QuickLaTeX Plugin for WordPress: Rendering TikZ Diagrams on a Blog
Translated from the Korean original. Read the original →
I've installed the QuickLaTeX plugin on my blog. In particular, QuickLaTeX can render TikZ images in posts. I'm already using MathJax on this blog, so I don't really need QuickLaTeX's equation rendering. However, MathJax cannot render TikZ images, so we may need this plugin just for plots, graphs and so on.
QuickLaTeX Plugin Download: http://www.holoborodko.com/pavel/quicklatex
Below are some simple examples of QuickLaTeX. If we write
\ begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}
\addplot3[surf,domain=0:360,samples=60] {cos(x)*cos(y)};
\end{axis}
\end{tikzpicture}
then QuickLaTeX renders it like this:
\begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}
\addplot3[surf,domain=0:360,samples=60] {cos(x)*cos(y)};
\end{axis}
\end{tikzpicture}
If rendering takes too long, we can reduce the number of samples used to plot the image, as below.
\ begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}
\addplot3[surf,domain=0:360,samples=20] {sin(x)*sin(y)};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}
\addplot3[surf,domain=0:360,samples=20] {sin(x)*sin(y)};
\end{axis}
\end{tikzpicture}
Here are some other typical examples, which can be found at http://www.texample.net/tikz/examples/all.
\ begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}[xlabel=Time (weeks),ylabel=Individuals,
width=12cm,height=6cm
]
\addplot coordinates {(1,8) (2,9) (4,7) (5,13)
(6,12) (8,18) (9,17) (10,22) (11,41) (12,32)
(13,24) (14,21) (16,21.5) (21,19.4) (25,21.02)};
\node[coordinate,pin={below:{Control}}] at (axis cs:16,21.5) {};
\addplot coordinates {(1,4) (2,3) (4,5) (5,7)
(6,9) (7,8) (8,12) (9,23) (10,38) (11,34)
(12,35) (13,33.2) (14,27) (16,25) (21,24.4) (25,24.9)};
\node[coordinate,pin={above:{Treatment}}] at (axis cs:21,24.4) {};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
[/preamble]
\begin{axis}[xlabel=Time (weeks),ylabel=Individuals,
width=12cm,height=6cm
]
\addplot coordinates {(1,8) (2,9) (4,7) (5,13)
(6,12) (8,18) (9,17) (10,22) (11,41) (12,32)
(13,24) (14,21) (16,21.5) (21,19.4) (25,21.02)};
\node[coordinate,pin={below:{Control}}] at (axis cs:16,21.5) {};
\addplot coordinates {(1,4) (2,3) (4,5) (5,7)
(6,9) (7,8) (8,12) (9,23) (10,38) (11,34)
(12,35) (13,33.2) (14,27) (16,25) (21,24.4) (25,24.9)};
\node[coordinate,pin={above:{Treatment}}] at (axis cs:21,24.4) {};
\end{axis}
\end{tikzpicture}
\ begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
thick,main node/.style={circle,fill=red!20,draw,font=\sffamily\Large\bfseries}]
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{arrows}
[/preamble]
\node[main node] (1) {A};
\node[main node] (2) [below left of=1] {B};
\node[main node] (3) [below right of=2] {C};
\node[main node] (4) [below right of=1] {D};
\path[every node/.style={font=\sffamily\small}]
(1) edge node [left] {a} (4)
edge [bend right] node[left] {b} (2)
edge [loop above] node {c} (1)
(2) edge node [right] {d} (1)
edge node {0.1} (4)
edge [loop left] node {100} (2)
edge [bend right] node[left] {20} (3)
(3) edge node [right] {0.04} (2)
edge [bend right] node[right] {40} (4)
edge [loop below] node {1} (3)
(4) edge node [left] {e} (3)
edge [loop right] node {f} (4)
edge [bend right] node[right] {g} (1);
\end{tikzpicture}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3cm,
thick,main node/.style={circle,fill=red!20,draw,font=\sffamily\Large\bfseries}]
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usetikzlibrary{arrows}
[/preamble]
\node[main node] (1) {A};
\node[main node] (2) [below left of=1] {B};
\node[main node] (3) [below right of=2] {C};
\node[main node] (4) [below right of=1] {D};
\path[every node/.style={font=\sffamily\small}]
(1) edge node [left] {a} (4)
edge [bend right] node[left] {b} (2)
edge [loop above] node {c} (1)
(2) edge node [right] {d} (1)
edge node {0.1} (4)
edge [loop left] node {100} (2)
edge [bend right] node[left] {20} (3)
(3) edge node [right] {0.04} (2)
edge [bend right] node[right] {40} (4)
edge [loop below] node {1} (3)
(4) edge node [left] {e} (3)
edge [loop right] node {f} (4)
edge [bend right] node[right] {g} (1);
\end{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{gnuplot]
[/preamble]
\ begin{tikzpicture}[scale=2]
\shade[top color=red,bottom color=gray!50]
(0,0) parabola (1.5,2.25) |- (0,0);
\draw (1.05cm,2pt) node[above]
{\$\displaystyle\int_0^{3/2} \!\!x^2\mathrm{d}x\$};
\draw[style=help lines] (0,0) grid (3.9,3.9)
[step=0.25cm] (1,2) grid +(1,1);
\draw[->] (-0.2,0) -- (4,0) node[right] {x};
\draw[->] (0,-0.2) -- (0,4) node[above] {f(x)};
\foreach \x/\xtext in {1/1, 1.5/1\frac{1}{2}, 2/2, 3/3}
\draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {\xtext};
\foreach \y/\ytext in {1/1, 2/2, 2.25/2\frac{1}{4}, 3/3}
\draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {\ytext};
\draw (-.5,.25) parabola bend (0,0) (2,4) node[below right] {x^2};
\end{tikzpicture}
[+preamble]
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{gnuplot]
[/preamble]
\begin{tikzpicture}[scale=2]
\shade[top color=red,bottom color=gray!50]
(0,0) parabola (1.5,2.25) |- (0,0);
\draw (1.05cm,2pt) node[above]
{$\displaystyle\int_0^{3/2} \!\!x^2\mathrm{d}x$};
\draw[style=help lines] (0,0) grid (3.9,3.9)
[step=0.25cm] (1,2) grid +(1,1);
\draw[->] (-0.2,0) -- (4,0) node[right] {$x$};
\draw[->] (0,-0.2) -- (0,4) node[above] {$f(x)$};
\foreach \x/\xtext in {1/1, 1.5/1\frac{1}{2}, 2/2, 3/3}
\draw[shift={(\x,0)}] (0pt,2pt) -- (0pt,-2pt) node[below] {$\xtext$};
\foreach \y/\ytext in {1/1, 2/2, 2.25/2\frac{1}{4}, 3/3}
\draw[shift={(0,\y)}] (2pt,0pt) -- (-2pt,0pt) node[left] {$\ytext$};
\draw (-.5,.25) parabola bend (0,0) (2,4) node[below right] {$x^2$};
\end{tikzpicture}
More in Blog Tips
See all- How to Use Different Fonts for English, Japanese, and Korean on a WordPress Blog
- How to Change Fonts on a WordPress Blog: Different Fonts for English, Japanese and Korean(1)
- QuickLaTeX Plugin for WordPress: Rendering TikZ Diagrams on a Blog
- Blog Statistics (2012.01.01 - 2013.02.05) [Tistory](2)
- My Tistory Blog Visitor Stats (2010.06.18 - 2012.11.08)(4)
Comments 0