LoginSignup
4
4

More than 5 years have passed since last update.

TeXコンパイル用のRakefile

Posted at

platex が使える事が前提。
日本語に対応しています。

namespace :c do

  task :default => "all"

  task :setup do
    @name = "plan_booklog"
  end

  task :tex1 =>[:setup] do
    mkdir "output" unless File.exists? "output"
    sh "platex -kanji=utf8 -output-directory=output #{@name}.tex"
  end

  task :bibtex do
    if File.exists? File.join(File.dirname(__FILE__), %w{ reference.bib }) then
      if(RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/) then
    sh "pbibtex -kanji=utf8 output/#{@name}"
      else
    sh "jbibtex -kanji=utf8 output/#{@name}"
      end
      sh "platex -kanji=utf8 -output-directory=output #{@name}.tex"
      sh "platex -kanji=utf8 -output-directory=output #{@name}.tex"
    end
  end

  task :tex =>[:tex1,:bibtex]

  desc "compile tex files as pdf"
  task :pdf =>[:tex] do
    sh "dvipdfmx -o output/#{@name}.pdf output/#{@name}.dvi"
  end

  task :open =>[:setup] do
    if(RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/) then
      sh "output/#{@name}.pdf"
    else
      sh "open output/#{@name}.pdf"
    end
  end

  desc "do all compiling task"
  task :all =>[:setup,:tex1,:bibtex,:pdf,:open]

  desc "cleanup output directory"
  task :cleanup do
    sh "rm -r output/*"
  end
end
4
4
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
4
4