**Discord** bot for typesetting **LaTeX** and **Python** programming.
Discord bot for typesetting LaTeX and Python programming.
The bot renders messages containg LaTeX code. Any message containing at least a pair of dollar signs $ or \begin will be rendered as a PNG image.
The bot also supports Markdown syntax within $\LaTeX$ messages.
The bot can also handle picture or tikzpicture environment.
LaTeX code is rendered by KaTeX. You can specify KaTeX options with the command !katex gistd id where gistid is the id of a public gist containing a JSON object.
Example of a Discord message and the generated image.
# Test
- Inline math : $x\mapsto x^2$ induces a bijection from $\mathbb R_+$ onto $\mathbb R_+$.
- tikzpicture image
\usetikzlibrary{quotes,angles}
\begin{tikzpicture}[thick,scale=5, every node/.style={scale=5}]
\draw
(3,-1) coordinate (a) node[right] {a}
-- (0,0) coordinate (b) node[left] {b}
-- (2,2) coordinate (c) node[above right] {c}
pic["$\alpha$", draw=orange, <->, angle eccentricity=1.2, angle radius=1cm]
{angle=a--b--c};
\end{tikzpicture}
- Python code
```python
def f(x):
return x**2
```
- Displaystyle math
$$
\int_{-\infty}^{+\infty}e^{-t^2}\mathrm{dt}=\sqrt\pi
$$
{
"macros": {
"\\cC": "\\mathcal{C}",
"\\cD": "\\mathcal{D}",
"\\cP": "\\mathcal{P}",
"\\la": "\\lambda",
"\\va": "\\varphi",
"\\dF": "\\mathbb{F}",
"\\dK": "\\mathbb{K}",
"\\dN": "\\mathbb{N}",
"\\dQ": "\\mathbb{Q}",
"\\dR": "\\mathbb{R}",
"\\dC": "\\mathbb{C}",
"\\dU": "\\mathbb{U}",
"\\dZ": "\\mathbb{Z}",
"\\lb": "\\left[\\!\\left[",
"\\rb": "\\right]\\!\\right]",
"\\card": "\\operatorname{card}",
"\\vect": "\\operatorname{vect}",
"\\dim": "\\operatorname{dim}",
"\\deg": "\\operatorname{deg}",
"\\ident": "\\operatorname{Id}",
"\\stab": "\\operatorname{Stab}",
"\\Im": "\\operatorname{Im}",
"\\Ker": "\\operatorname{Ker}",
"\\conj": "\\overline",
"\\te": "\\theta",
"\\eps": "\\epsilon",
"\\si": "\\sigma",
"\\al": "\\alpha"
}
}
Use the !python command to interpret Python code.
Example of a Python message and generated output
!python
def doubles(l):
return [2*x for x in l]
print(doubles(range(10)))
Code
def doubles(l):
return [2*x for x in l]
print(doubles(range(10)))
Sortie
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
You can use the numpy package.
You can also the matplotlib package. Each call to show() will generate an image.
Example of a message using numpy and matplotliband the generated output.
!python
import numpy as np
import matplotlib.pyplot as plt
X=np.linspace(0,1,100)
Y=np.exp(X)
plt.plot(X,Y)
plt.show()
Code
import numpy as np
import matplotlib.pyplot as plt
X=np.linspace(0,1,100)
Y=np.exp(X)
plt.plot(X,Y)
plt.show()
Sortie
python
0
리뷰 0개
리뷰는 등록된 사용자만 남길 수 있습니다. 모든 리뷰는 Top.gg의 사이트 중재자가 관리합니다. 게시하기 전 저희의 지침을 반드시 확인해 주세요.
별점 5점
0
별점 4점
0
별점 3점
0
별점 2점
0
별점 1점
0
아직 리뷰가 없습니다!