11
12

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.

ATOMでplatexを使う(latexmkを用いてpdfを吐き出させる)

Last updated at Posted at 2016-06-11

※ 最新版のlatexパッケージでdvi経由のpdf作成ができるようになっているようです.

概要
Atomとplatexを用いてtex→dvi→pdfを行う。
今回はBuildからlatexmkを立ち上げる。

なぜplatexを使いたいか

  • 日本語の論文はまだplatex用のクラス指定が多いこと
  • platexはxelatex、lualatexと比べて軽いこと(体感なので未検証)
  • bibtexを使いたいこと(SIAM等bibtex用のスタイルファイルしか出していないところがある)

環境

  • Ubuntu 15.10
  • TeXLive 2015
  • Atom 1.7.4

実装

1. 準備

今回は論文を書くとして次のPaperをプロジェクトフォルダにしたとする

Paper
├── Python
├── Tex
│   ├── 00_Command.sty
│   ├── 00_Reference.bib
│   ├── 00_Style.sty
│   ├── Index.tex
│   └── .latexmkrc
└── .atom-build.json

また、latexmk(texliveに標準で付いているlatex自動コンパイルソフト)にパスが通っているとする

2. ATOMに必要なパッケージをインストールする。

今回必要なのはbuildのみ。次のどちらかの方法でインストールする

  • コンピュータの端末(コマンドプロンプトで)apm intstall buildと打つ
  • AtomでCtrl-,→パッケージ→buildで検索→インストール

3. Buildのための設定ファイルを書く

Paper/.atom-build.json
{
    "cmd": "latexmk -bibtex {FILE_ACTIVE}",
    "cwd": "{FILE_ACTIVE_PATH}"
}
Paper/Tex/.latexmkrc
$latex = 'platex -synctex=1 -interaction=nonstopmode %O %S';
$bibtex = 'pbibtex %O %B';
$dvipdf = 'dvipdfmx %O -o %D %S';
$max_repeat = 3;
$pdf_mode = 3;
$pvc_view_file_via_temporary = 0;

4. ctrl-alt-bでビルドできるようにする(※その他1参照)

Atomの設定からkeymap.csonを開いて一番最後に

keymap.cson
"body:not([class~='platform-darwin']) atom-text-editor[data-grammar~='latex']":
    'ctrl-alt-b': 'build:trigger'

を付け加える

5. テストする

今回は次の内容を用いてテストした。

ctrl-alt-bでpdfが出てくれば成功。

Paper/TeX/Index.tex
\documentclass[10pt,a4paper]{article}
\usepackage{00_Command}
\usepackage{00_Style}
\usepackage{empheq,amsfonts}
\usepackage{physics}
\begin{document}
    \section{問題}
        昔々、あるところにおじいさんとおばあさんがいました。
        おばあさんが川で洗濯していたところ、
        上流から速度$v(t)$で桃が流れてきました。
        ここで$v(t)$は、
        \begin{align}
            \dv[3]{v}{t} + \cos\qty(\frac{2\pi t}{T})v
            + \sin\qty(\frac{2\pi t}{T}) = 0
        \end{align}
        を満たすものとします\cite{ronbun1}。ここで$T$は定数です。
        $v(t)$を求めなさい。
    \bibliographystyle{siam}
    \bibliography{00_Reference}
\end{document}
Paper/TeX/00_Reference.bib
@article{ronbun1,
  title={桃の挙動に関する論文},
  author={太郎, 桃},
  journal={昔話研究ジャーナル},
  volume={100},
  number={2},
  pages={123--456},
  year={2018},
  publisher={竹取り出版社}
}

その他

  1. latexやlatex-toolsなどのパッケージが入っていると思うので
    そこら辺を何とかするための設定。
    ビルドが一番強い時はこの設定は多分いらないと思います。
  2. Buildの設定ファイルはプロジェクトフォルダ直下に置かないといけない。
  3. 自作コマンドのファイル名に00_をつけているのは、ファイル名順に並べた時に上に来て欲しいだけのことで特に意味はない
11
12
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
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?