LoginSignup
11
11

More than 5 years have passed since last update.

Ubuntu14.04でTeX環境構築

Last updated at Posted at 2015-10-20

やったこと

以下のコマンドを実行し、シェルを再起動

$ sudo apt-get install texlive # TeXそのもの
$ sudo apt-get install texlive-lang-cjk # 日本語対応版(UTF-8)
$ sudo apt-get install texlive-fonts-recommended texlive-fonts-extra # フォント(なくてもいけるかも…)
コンパイル
$ platex sample.tex
# このコマンドで sample.aux sample.dvi が生成されます
dviをpdf形式に変換
$ dvipdfm sample.dvi
# このコマンドで sample.pdf が生成されます

あとは以下のコマンドとかで開いてみる

$ evince sample.pdf

おまけ

僕はVimを使っているため、Vim上からコンパイルとPDFを開きたかったので、vim-latexのインストールと設定をしました。

私はNeoBundleを使いました。

.vimrc
NeoBundle 'vim-latex/vim-latex'

" Vim-LaTeX
" 各オプションは各自でお調べください
set shellslash
set grepprg=grep\ -nH\ $*
let tex_flavor='latex'
let g:Tex_DefaultTargetFormat='pdf'
let g:Tex_MultipleCompileFormats='dvi,pdf'
let g:Tex_FormatDependency_pdf='dvi,pdf'
let g:Tex_CompileRule_dvi='platex --interaction=nonstopmode $*'
let g:Tex_CompileRule_pdf='dvipdfm $*.dvi'
let g:Tex_ViewRule_pdf='evince'

追記

EvinceでPDFを表示したときに日本語の明朝体がゴシック体として表示されてしまう問題を直す方法が、TeX Wikiにあったので載せておきます。

以下のコマンド実行

$ mkdir ~/.config/fontconfig/
$ touch ~/.config/fontconfig/fonts.conf

新しく作成された fonts.conf のファイルを以下の内容を追加

~/.config/fontconfig/fonts.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <dir>/usr/local/texlive/2015/texmf-dist/fonts/truetype/public/ipaex</dir>
  <dir>/usr/share/texlive/texmf-dist/fonts/truetype/public/ipaex</dir>
  <dir>/usr/share/texmf-dist/fonts/truetype/public/ipaex</dir>
  <dir>/usr/share/texmf/fonts/truetype/public/ipaex</dir>
  <match target="pattern">
    <test qual="any" name="family">
      <string>Ryumin</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>IPAexMincho</string>
    </edit></match><match target="pattern">
    <test qual="any" name="family">
      <string>GothicBBB</string>
    </test>
    <edit name="family" mode="prepend" binding="strong">
      <string>IPAexGothic</string>
    </edit>
  </match>
</fontconfig>

参考

モダンな日本語 TeX 環境を整える

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