-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
41 lines (33 loc) · 915 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require 'active_support/core_ext/string'
name = 'nonlocal_spin_valve'
build_name = name.titlecase
tex_src = 'tex'
build = 'build'
task :default => :build
desc 'Build LaTeX.'
task build: [:tex]
desc 'Compile LaTeX to PDF.'
task :tex do
FileUtils.mkdir_p build
path = File.join tex_src, "#{name}.tex"
fail RuntimeError, "Error: #{path} not found." unless File.exists? path
Dir.chdir tex_src do
system 'latexmk', '-xelatex', '-f', "#{name}.tex"
FileUtils.mv "#{name}.pdf", File.join('../', build, "#{build_name}.pdf")
end
end
desc 'Clean out temporary LaTeX files.'
task :clean do
Dir.chdir tex_src do
system 'latexmk', '-c'
%w(fls bbl bib).each do |ext|
Dir.glob("*.#{ext}") { |f| File.unlink f }
end
end
end
desc 'Create png preview.'
task png: [:tex] do
Dir.chdir build do
system 'convert', '-density', '300', "#{build_name}.pdf", "#{build_name}.png"
end
end