1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

KaTeX@VSCode の日本語での分数に上下の余白を入れる

Posted at

はじめに

VSCode で Markdown All in OneMarkdown Preview Enhanced を使って数式をプレビューする際は KaTeX が使われますが、英数字ではなく日本語で分数(frac)を表現すると括線との隙間がほとんどない状態で表現されます。特にインライン数式ではそれが顕著です。
image.png
とりあえず上2つについて、強引に見た目だけでも余白を入れます。

やりかた

なるべく幅が小さい文字 | を使って上下に余白を入れつつ \phantom で見えなくします。

  • 分子| を入れるだけで下側に余白が生じるので、バランスを取って両脇に入れます。
  • 分母:どの文字を入れても上側に余白は生じないので、\vec| としてベクトルの矢印も入れて強引に余白を入れます。分子と同様に両脇に入れますが、矢印の有無で幅は変わらないため片方はただの | で良いです。
\frac{分子}{分母} \frac{|分子|}{|分母\vec|} \frac{\phantom|分子\phantom|}{\phantom|分母\phantom{\vec|}}
1 image.png image.png image.png
2 image.png image.png image.png

おわりに

あまり必要なシーンはないでしょうし、もっと環境設定的な話もあるかも知れませんが、手軽なその場しのぎとしては使えると思います。

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?