LoginSignup
23
25

More than 5 years have passed since last update.

Atomで日本語TeXをコンパイル可能にした話

Last updated at Posted at 2015-05-30

AtomにはTeXをコンパイル可能にするパッケージが存在しています。
それが https://atom.io/packages/latex です。
thomasjo氏が配布しているこのパッケージは素晴らしいですが、
コンパイル方法がpdflatex,lualatex,xelatexの3つだけしかありません。
そのため、日本語をコンパイルすることができませんでした。

そこで、日本語のTexをコンパイルできるようにした内容を備忘録として書き留めておこうと思います。

まずpdflatexでも日本語をコンパイル可能にするためにbxcjkjatypeパッケージを使用しました。

そしてプリアンブル部分に次のように記述しました。

tex
\documentclass[12pt,a4paper]{report}
\usepackage[whole]{bxcjkjatype}

これで、コンパイルが可能になります。

しかし、このままだと第何章という表記ではなく、Chapter ○ という表記になっています。
また、タイトルが2行目に来てしまう問題があります。
(このままでもいいのかもしれないが、今まで使っていたujreportの表記と変わってしまうのが気に食わなかった)

そこで、report.clsファイルの中身を書き換えることにしたのでメモしておきます。
変更する際は バックアップを取ることをおすすめ します。

変更箇所が多いので、該当箇所のbefore,afterを対にして表記します。
一部のみの変更も多いのでよく見比べてもらえると助かります。

before1
\newcommand\@chapapp{\chaptername}

\newcommand\chaptername{Chapter}
after1
\newcommand\@chapapp{\prechaptername}
\newcommand\@chappos{\postchaptername}

\newcommand\prechaptername{Chapter}
\newcommand\postchaptername{}


before2
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else

after2
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter\space\@chappos.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else


before3
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  \vspace*{\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter\space \@chappos
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
after3
\def\@makechapterhead#1{%
  % \vspace*{50\p@}%
  \vspace*{\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries \@chapapp\space \thechapter\space \@chappos\space\space \Huge \bfseries #1
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    % \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}


before4(2箇所)
\def\chaptermark##1{%
      \markboth {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter. \ %
        \fi
        ##1}}{}}%
after4(2箇所)
\def\chaptermark##1{%
      \markboth {\MakeUppercase{%
        \ifnum \c@secnumdepth >\m@ne
            \@chapapp\ \thechapter\ \@chappos. \ %    <=ここだけ
        \fi
        ##1}}{}}%


before5
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else
after5
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter\space\@chappos.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                    \else

以上の箇所を変更することで、ujreportクラスをplatexしてpdf出力したときと似たようなレイアウトになる(はず)。

最後にtexのプリアンブル部分に第何章表記にするためのコマンドを書き足して終了。

tex
\renewcommand{\prechaptername}{}
\renewcommand{\postchaptername}{}

雑な記述ですが、自分と似たようなことをしようとしている人の助けになればと思います。


追記:

Atom + MacTeX2015 + OS X ElCapitan 環境で再度構築して、動作を確認しました。
report.clsファイルが新しく作られるので、このページの内容を再度行えばujreport.clsと同等になりました。

23
25
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
23
25