LoginSignup
2
2

More than 5 years have passed since last update.

XeLaTeXで日本語を含むソースコードを表示する。

Posted at

TeXの文書にコードを入れるのにlistingsをよく使うのですが、listingsがデフォルトでは日本語に対応してません。

「listings 日本語」で検索するとjlistingを合わせて使えって記事が多いんですが、jlistingはlastline使うとバグるので、ここではjlistingを使わない方法を紹介します。

XeLaTeXの場合は、\usepackage{xeCJK}xeCJKを読み込むと、listingsで日本語を使っても表示がくずれなくなります。

自分の場合は、TeX Live 2014をインストールしたときにxeCJKのパッケージは含まれていたので、個別にインストールする必要はありませんでした。

xeCJKを使う場合は日本語フォントの指定も必要になるので、実際には以下のような内容を追加します。

\usepackage{xeCJK}
\setCJKmainfont{IPAPMincho}
\setCJKsansfont{IPAPGothic}
\setCJKmonofont{IPAGothic}
2
2
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
2
2