|
本帖最后由 hbghlyj 于 2022-6-21 15:55 编辑
用Node.js搞了一个应用程序,它可以把你发送的tex文档用pdflatex/xelatex/...转换为pdf,然后用pdf2svg转换为svg,再发给你,并且缓存最近30天的所有图片,例如- window.open("http://tex.cjhb.site?tex="+encodeURIComponent("\\documentclass[10pt,crop,tikz]{standalone}\\usepackage{tikz-cd}\\usepackage{amsmath}\\usepackage{amsfonts}\\usepackage{mathrsfs}\\begin{document}\\begin{tikzpicture}\\draw[gray, thick] (-1,2) -- (2,-4);\\draw[gray, thick] (-1,-1) -- (2,2);\\filldraw(0,0) circle (2pt) node[anchor=west]{Intersection point};\\end{tikzpicture}\\end{document}"))
复制代码
- window.open("http://tex.cjhb.site?tex="+encodeURIComponent("\\documentclass[10pt,crop,tikz]{standalone}\\usepackage{tikz-cd}\\usepackage{amsmath}\\usepackage{amsfonts}\\usepackage{mathrsfs}\\begin{document}\\begin{tikzpicture}[>=latex,line width=1pt,x=4cm,y=4cm] \\draw[->] (-1.5,0)--(1.5,0) node[right] {$x$}; \\draw[->] (0,-1.5) node[below=10pt] {$\\displaystyle S=\\frac{12}{5}\\arctan\\left[\\sqrt{265+118 \\sqrt{5}-2 \\sqrt{30\\left(1165+521 \\sqrt{5}\\right)}}\\,\\right]-\\frac{3 \\sqrt{15}}{160}$} --(0,1.5) node[above] {$y$}; \\filldraw[draw=red,fill=red!50,fill opacity=0.5] (1,0) \\foreach \\i in {0,...,4} { -- plot[domain={\\i*144}:{\\i*144+144},smooth] ({3/5*cos(\\x)+2/5*cos(3*\\x/2)},{3/5*sin(\\x)-2/5*sin(3*\\x/2)}) }; \\node[red,below left] at (-0.8,-0.6) {$\\left\\{\\begin{aligned} x&=\\frac35\\cos(t)+\\frac25\\cos\\left(\\frac{3t}{2}\\right)\\\\ y&=\\frac35\\sin(t)-\\frac25\\sin\\left(\\frac{3t}{2}\\right) \\end{aligned}\\right.$}; \\fill[blue] ({(1+sqrt(5))/16},{(1+sqrt(5))/16*tan(pi/5 r)}) circle (2pt) node[above right] {$\\displaystyle \\left(\\frac{1+\\sqrt5}{16}, \\frac{1+\\sqrt5}{16}\\tan\\frac\\pi5\\right)$}; \\end{tikzpicture}\\end{document}"))
复制代码
此外,参数"engine"的缺省值是pdflatex,它还可以选择xelatex(比如需要使用pstricks时),也可以为lualatex(比如需要tikzlibrary graphdrawing时).
lualatex示例:- window.open("http://tex.cjhb.site?engine=lualatex&tex="+encodeURIComponent('\\documentclass{standalone} \\usepackage{tikz}\\usetikzlibrary{graphdrawing} \\usetikzlibrary{graphs} \\usegdlibrary{trees} \\begin{document} \\begin{tikzpicture}[>=stealth, every node/.style={circle, draw, minimum size=0.75cm}] \\graph [tree layout, grow=down, fresh nodes, level distance=0.5in, sibling distance=0.5in] { 4 -> { 3 -> { 1 -> { 5, " " }, 2,2 }, 3 -> { 1, 2, 2 }, 3 -> { 1, 2, 2 } } }; \\end{tikzpicture} \\end{document}'))
复制代码 xelatex示例:- window.open("http://tex.cjhb.site?engine=xelatex&tex="+encodeURIComponent('\\documentclass[12pt,pstricks,border=15pt]{standalone}\n\\usepackage{pstricks}\n\\begin{document}\n\\def\\myFig{\n \\pscustom[fillstyle=solid,fillcolor=yellow,opacity=.5]{%\n \\psarcn(3,0){3}{180}{90}\\psarcn(1,3){2}{0}{-90}\n \\psarc(1,2){1}{-90}{0}\\psarc(2,0){2}{90}{180}\n }\n \\pscustom[fillstyle=solid,fillcolor=blue,opacity=.5]{%\n \\psarc(0,3){3}{-90}{0}\\psarcn(1,3){2}{0}{-90}\n \\psarcn(2,1){1}{180}{90}\\psarc(2,0){2}{90}{180}\n \\closepath\n }\n}\n\n\\begin{pspicture}(0,0)(6,6)\n\\rput(0,3){\\myFig}\n\\rput{-270}(6,3){\\myFig}\n\\rput{180}(6,3){\\myFig}\n\\rput{-90}(0,3){\\myFig}\n\\end{pspicture}\n\\end{document}'))
复制代码 |
|