TeXclipでTikZが使えたので驚いた！

TeXclipはTeXで書いた文章の画像を生成するオンラインのサービスです。

https://texclip.marutank.net/

デフォルトでは以下のようになっています。

```tex
\begin{align*}
  \left( \int_0^\infty \frac{\sin x}{\sqrt{x}} dx \right)^2 =
  \sum_{k=0}^\infty \frac{(2k)!}{2^{2k}(k!)^2} \frac{1}{2k+1} =
  \prod_{k=1}^\infty \frac{4k^2}{4k^2 - 1} = \frac{\pi}{2}
\end{align*}
```

例えば

```tex
$$
i\hbar \frac{\partial}{\partial t} \psi = \hat H \psi
$$
```

と書いて，「Generate」またはCtrl+Sで次のように画像が生成されます。

![](https://texclip.marutank.net/render.php/texclip20230703043911.png?s=%24%24%0Ai%5Chbar%20%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20t%7D%20%5Cpsi%20%3D%20%5Chat%20H%20%5Cpsi%0A%24%24&f=c&r=300&m=p&b=f&k=f)



ソースコード
https://texclip.marutank.net/#s=%24%24%0Ai%5Chbar%20%5Cfrac%7B%5Cpartial%7D%7B%5Cpartial%20t%7D%20%5Cpsi%20%3D%20%5Chat%20H%20%5Cpsi%0A%24%24

生成した画像のURLを貼り付けることもできます。
右クリック→「画像のアドレスをコピー」→貼り付け

`![]()`で画像を呼び出すとき，URLに`( )`が含まれているとうまく呼び出すことができないことがあります。`<img src="">`を使いましょう。


日本語の入力に対応しています。

<img src="https://texclip.marutank.net/render.php/texclip20230704013531.svg?s=%24%5Comega%24%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%81%8C%E5%90%AB%E3%81%BE%E3%82%8C%E3%81%A6%E3%81%84%E3%81%A6%E3%82%82%E5%A4%A7%E4%B8%88%E5%A4%AB%E3%81%A7%E3%81%99%E3%80%82%24%5Comega%24&f=c&r=1200&m=s&b=f&k=f">

↓ソースコード

https://texclip.marutank.net/#s=%24%5Comega%24%E6%97%A5%E6%9C%AC%E8%AA%9E%E3%81%8C%E5%90%AB%E3%81%BE%E3%82%8C%E3%81%A6%E3%81%84%E3%81%A6%E3%82%82%E5%A4%A7%E4%B8%88%E5%A4%AB%E3%81%A7%E3%81%99%E3%80%82%24%5Comega%24


# TikZを使う

TeXでTikZを書くのとまったく同じです。ライブラリを使うこともできます。

```tex
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\fill (0,0) circle (2pt);
\end{tikzpicture}
```
<img src="https://texclip.marutank.net/render.php/texclip20230703042054.svg?s=%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(0%2C0)%20circle%20(2cm)%3B%0A%5Cfill%20(0%2C0)%20circle%20(2pt)%3B%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f">

↓ソースコード

https://texclip.marutank.net/#s=%5Cbegin%7Btikzpicture%7D%0A%5Cdraw%20(0%2C0)%20circle%20(2cm)%3B%0A%5Cfill%20(0%2C0)%20circle%20(2pt)%3B%0A%5Cend%7Btikzpicture%7D




```tex
\usetikzlibrary{patterns}%ライブラリ
\begin{tikzpicture}
\fill[pattern = north west lines] (0,0) rectangle (4,4);
\end{tikzpicture}
```
![](https://texclip.marutank.net/render.php/texclip20230703042350.svg?s=%5Cusetikzlibrary%7Bpatterns%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cfill%5Bpattern%20%3D%20north%20west%20lines%5D%20(0%2C0)%20rectangle%20(4%2C4)%3B%0A%5Cend%7Btikzpicture%7D&f=c&r=600&m=s&b=f&k=f)

↓ソースコード

https://texclip.marutank.net/#s=%5Cusetikzlibrary%7Bpatterns%7D%0A%5Cbegin%7Btikzpicture%7D%0A%5Cfill%5Bpattern%20%3D%20north%20west%20lines%5D%20(0%2C0)%20rectangle%20(4%2C4)%3B%0A%5Cend%7Btikzpicture%7D


`\usepackage`は使用できない?ので`tikz-3dplot`は使用できませんが，3dの描画はできます。
`perspective`ライブラリなどを読み込むと，カメラアングルを緯度と経度で指定することができます。

![](https://texclip.marutank.net/render.php/texclip20230711033247.svg?s=%5Cusetikzlibrary%20%7Bperspective%7D%0A%5Cbegin%7Btikzpicture%7D%5B3d%20view%3D%7B130%7D%7B30%7D%5D%0A%5Cdraw%5B-latex%5D%20(0%2C0%2C0)%20--%20(5%2C0%2C0)%20node%5Bpos%3D1.1%5D%20%7B%24x%24%7D%3B%0A%5Cdraw%5B-latex%5D%20(0%2C0%2C0)%20--%20(0%2C5%2C0)%20node%5Bpos%3D1.1%5D%20%7B%24y%24%7D%3B%0A%5Cdraw%5B-latex%5D%20(0%2C0%2C0)%20--%20(0%2C0%2C5)%20node%5Bpos%3D1.1%5D%20%7B%24z%24%7D%3B%0A%5Cforeach%20%5Cx%20in%20%7B0%2C...%2C5%7D%0A%09%7B%0A%09%5Cdraw%5Bhelp%20lines%5D%20(0%2C%5Cx%2C0)%20--%20(5%2C%5Cx%2C0)%3B%0A%09%5Cdraw%5Bhelp%20lines%5D%20(%5Cx%2C0%2C0)%20--%20(%5Cx%2C5%2C0)%3B%0A%09%7D%0A%5Cfill%5Bblue%2Copacity%3D0.7%5D%20(3%2C0%2C0)%20--%20(3%2C3%2C0)%20--%20(3%2C3%2C3)%20--%20(3%2C0%2C3)%20--%20cycle%3B%0A%5Cfill%5Bblue!60!white%2Copacity%3D0.7%5D%20(0%2C3%2C0)%20--%20(3%2C3%2C0)%20--%20(3%2C3%2C3)%20--%20(0%2C3%2C3)%20--%20cycle%3B%0A%5Cfill%5Bblue!30!white%2Copacity%3D0.7%5D%20(0%2C0%2C3)%20--%20(3%2C0%2C3)%20--%20(3%2C3%2C3)%20--%20(0%2C3%2C3)%20--%20cycle%3B%0A%5Cend%7Btikzpicture%7D&f=c&r=300&m=s&b=f&k=f)

↓ソースコード

https://texclip.marutank.net/#s=%5Cusetikzlibrary%20%7Bperspective%7D%0A%5Cbegin%7Btikzpicture%7D%5B3d%20view%3D%7B130%7D%7B30%7D%5D%0A%5Cdraw%5B-latex%5D%20(0%2C0%2C0)%20--%20(5%2C0%2C0)%20node%5Bpos%3D1.1%5D%20%7B%24x%24%7D%3B%0A%5Cdraw%5B-latex%5D%20(0%2C0%2C0)%20--%20(0%2C5%2C0)%20node%5Bpos%3D1.1%5D%20%7B%24y%24%7D%3B%0A%5Cdraw%5B-latex%5D%20(0%2C0%2C0)%20--%20(0%2C0%2C5)%20node%5Bpos%3D1.1%5D%20%7B%24z%24%7D%3B%0A%5Cforeach%20%5Cx%20in%20%7B0%2C...%2C5%7D%0A%09%7B%0A%09%5Cdraw%5Bhelp%20lines%5D%20(0%2C%5Cx%2C0)%20--%20(5%2C%5Cx%2C0)%3B%0A%09%5Cdraw%5Bhelp%20lines%5D%20(%5Cx%2C0%2C0)%20--%20(%5Cx%2C5%2C0)%3B%0A%09%7D%0A%5Cfill%5Bblue%2Copacity%3D0.7%5D%20(3%2C0%2C0)%20--%20(3%2C3%2C0)%20--%20(3%2C3%2C3)%20--%20(3%2C0%2C3)%20--%20cycle%3B%0A%5Cfill%5Bblue!60!white%2Copacity%3D0.7%5D%20(0%2C3%2C0)%20--%20(3%2C3%2C0)%20--%20(3%2C3%2C3)%20--%20(0%2C3%2C3)%20--%20cycle%3B%0A%5Cfill%5Bblue!30!white%2Copacity%3D0.7%5D%20(0%2C0%2C3)%20--%20(3%2C0%2C3)%20--%20(3%2C3%2C3)%20--%20(0%2C3%2C3)%20--%20cycle%3B%0A%5Cend%7Btikzpicture%7D