自分用 Word Press 使い方メモ

数式をTeXを使って表示させる

プラグイン『MathJax-LaTeX』を使う。

基本的な使い方2パターン

1.1行に数式のみ書く
2.文の中に数式を入れる。

ただ表示させたいところに書くだけ!
※書いた数式は直ちに数式に変換されるわけではなく、LaTeXのコマンドがそのまま表示され、プレビュー画面などから見てようやく数式になっていることが確認できる。

1. 1行に数式のみ書く

1行に数式のみ書く場合(推奨版ではないけど書きやすい):単に$$$$で囲む

$$ 
 \int_{-\infty}^\infty e^{-ax^2}~dx=\sqrt{\frac{\pi}{a}}
$$

$$
\int_{-\infty}^\infty e^{-ax^2}~dx=\sqrt{\frac{\pi}{a}}
$$

1行に数式のみ書く場合(推奨版。左寄せになる。(Jetpackが有効な時)):『\(』と『\)』で囲む

\( y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases} x &\text{if} \,\, x \geq 0 \\ 0 &\text{otherwise} \end{cases} \)

\( y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases} x &\text{if} \,\, x \geq 0 \\ 0 &\text{otherwise} \end{cases} \)

ちなみに改行などをするとうまくいかなくなる↓

\(
y = \operatorname{ReLU}(x) \quad \text{where} \,\,
\operatorname{ReLU}(x) = 
\begin{cases} 
x &\text{if} \,\, x \geq 0 \ 0 &\text{otherwise} 
\end{cases}
\)

↓なぜか場合分けが…

\(
y = \operatorname{ReLU}(x) \quad \text{where} \,\,
\operatorname{ReLU}(x) = 
\begin{cases} 
x &\text{if} \,\, x \geq 0 \ 0 &\text{otherwise} 
\end{cases}
\)

1行に数式のみ書く場合(MathJaxを使用時)

『\[』と『\]』で囲む
\[ y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases} x &\text{if} \,\, x \geq 0 \\ 0 &\text{otherwise} \end{cases} \]

\[ y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases} x &\text{if} \,\, x \geq 0 \\ 0 &\text{otherwise} \end{cases} \]

ちなみに改行などをするとうまくいかなくなる↓

\[
y = \operatorname{ReLU}(x) \quad \text{where} \,\,
\operatorname{ReLU}(x) = 
\begin{cases} 
x &\text{if} \,\, x \geq 0 \ 0 &\text{otherwise} 
\end{cases}
\]

↓なぜか場合分けが…

\[
y = \operatorname{ReLU}(x) \quad \text{where} \,\,
\operatorname{ReLU}(x) = 
\begin{cases} 
x &\text{if} \,\, x \geq 0 \ 0 &\text{otherwise} 
\end{cases}
\]

2. 文の中に数式を入れる。


文の中に数式を入れる場合(MathJaxを使用時):『\(』と『\)』で囲む

あいうえお\(e^{-ax^2}\)かきくけこ

あいうえお\(e^{-ax^2}\)かきくけこ

『[latex]』と『[/latex]』版、$$版 の違い

『[latex]』と『[/latex]』版。
なのだが、なぜかこの大事な部分が変換されている。
実際には『[latex]』と『[/latex]』を\(たちの代わりに使っている。

\(
y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases}
x &\text{if} \,\, x \geq 0 \\
0 &\text{otherwise}
\end{cases}
\)
\(
y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases}
x &\text{if} \,\, x \geq 0 \\
0 &\text{otherwise}
\end{cases}
\)

$$版

$$
y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases}
x &\text{if} \,\, x \geq 0 \\
0 &\text{otherwise}
\end{cases}
$$

$$
y = \operatorname{ReLU}(x) \quad \text{where} \,\, \operatorname{ReLU}(x) = \begin{cases}
x &\text{if} \,\, x \geq 0 \\
0 &\text{otherwise}
\end{cases}
$$

その他の使い方

上付き文字、下付き文字

数式の中に入れ込む。

\(X_1\)

とすると、\(X_1\)と書くことができる。

さらに色んな使い方

ワードプレスで LaTeX を使って見ました.
⇨数式番号の表示, new commandの自作(関数の自作的な), amsmath パッケージに含まれる記号の使い方

コメント