0
0

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 5 years have passed since last update.

LaTeXでタイプライター風に ”_” (アンダーバー)を出力する方法

Last updated at Posted at 2019-06-30

_を素直にエスケープして書くとどうなるか

LaTeXでは アンダーバー(アンダースコア)_ は下付き文字を表すのでエスケープして \_とするのだが、素直に

tex
{\tt under\_bar}

と書いて出力するとアンダーバーがタイプライター調にならない、、(QiitaではLaTeXではなくMathJaxを使っていてこの方法でうまくいったのでここでは表示していない)
これは、LaTeXでは\_によるアンダーバーが線分として定義されていて、フォントという概念がそもそも存在しないためらしい。

解決法

入力した文字をそのまま出力するコマンド\verb|foo|を使って

tex

{\tt \verb|under_bar|}

とすれば


\texttt{under}\_\texttt{bar}

とアンダーバーもタイプライター調になって出力される!

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?