texlab 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/texlab-compile +1 -1
- data/lib/texlab.rb +3 -16
- data/lib/texlab/boot.rb +69 -5
- data/lib/texlab/texlabfile.rb +3 -1
- data/texlab.gemspec +2 -3
- metadata +25 -26
- data/lib/texlab.rake +0 -7
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.1.0
|
data/bin/texlab-compile
CHANGED
data/lib/texlab.rb
CHANGED
@@ -1,20 +1,7 @@
|
|
1
|
-
# To be sourced in VIM at startup
|
2
|
-
|
3
|
-
# Set up path
|
4
|
-
$: << (ENV["TEXLAB"]+"/lib") << (ENV["TEXLAB"]+"/lib/ruby")
|
5
|
-
Dir.glob(ENV["TEXLAB"]+"/gems/**/lib").each do |dir|
|
6
|
-
$: << dir
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
require "rubygems"
|
11
|
-
#require "irb"
|
12
|
-
require "yaml"
|
13
1
|
require "rake4latex"
|
14
2
|
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
desc "Compile a texlab file to tex"
|
4
|
+
rule ".tex" => ".texlab" do |t|
|
5
|
+
sh %("texlab-compile" "#{t.source}")
|
18
6
|
end
|
19
7
|
|
20
|
-
|
data/lib/texlab/boot.rb
CHANGED
@@ -174,10 +174,11 @@ def plot *args
|
|
174
174
|
opts = args.extract_options!
|
175
175
|
title = args[0]
|
176
176
|
|
177
|
-
placement = opts.delete(:placement) || "htbp"
|
177
|
+
placement = opts.delete(:placement) || (opts[:label] ? "htbp" : "H")
|
178
178
|
width = opts.delete(:width) || "17cm"
|
179
179
|
height = opts.delete(:height) || "10cm"
|
180
180
|
cmd = opts.delete(:cmd) || "plot"
|
181
|
+
label = opts.delete(:label)
|
181
182
|
|
182
183
|
env :figure, "[#{placement}]" do
|
183
184
|
env :center do
|
@@ -215,6 +216,7 @@ def plot *args
|
|
215
216
|
end
|
216
217
|
end
|
217
218
|
$_erbout << "\\caption{#{title}}" if title
|
219
|
+
$_erbout << "\\label{#{label}}" if label
|
218
220
|
end
|
219
221
|
end
|
220
222
|
|
@@ -332,16 +334,28 @@ def macro hash
|
|
332
334
|
text_macro hash.mash{|key, value| [key, value.latex!.to_latex_math] }
|
333
335
|
end
|
334
336
|
|
335
|
-
# a text macro is available in tex (\asdf) and in ruby (:asdf). It will not be
|
337
|
+
# a text macro is available in tex (\asdf) and in ruby (:asdf, $asdf). It will not be
|
336
338
|
# forced to math mode
|
337
339
|
def text_macro hash
|
338
340
|
hash.each do |key, value|
|
339
|
-
|
340
|
-
|
341
|
-
|
341
|
+
define_latex_macro key, value
|
342
|
+
define_symbol_macro key, value
|
343
|
+
define_global_macro key, value
|
342
344
|
end
|
343
345
|
end
|
344
346
|
|
347
|
+
def define_symbol_macro key, value
|
348
|
+
$_macros[key] = value
|
349
|
+
end
|
350
|
+
|
351
|
+
def define_latex_macro key, value
|
352
|
+
$_erbout << "\\def\\#{key}{#{value}}"
|
353
|
+
end
|
354
|
+
|
355
|
+
def define_global_macro key, value
|
356
|
+
eval "$#{key} = '#{value.gsub("\\","\\\\").gsub("'", "\\'")}'"
|
357
|
+
end
|
358
|
+
|
345
359
|
class Symbol
|
346
360
|
# symbol's to_latex is the macro with the same name
|
347
361
|
def to_latex
|
@@ -351,9 +365,52 @@ class Symbol
|
|
351
365
|
def + str
|
352
366
|
"#{to_latex}#{str}".latex!.to_latex_math
|
353
367
|
end
|
368
|
+
|
369
|
+
def * unit
|
370
|
+
"\\unit[\\text{#{to_latex}}]{#{unit}}".latex!.to_latex_math
|
371
|
+
end
|
354
372
|
end
|
355
373
|
|
356
374
|
|
375
|
+
|
376
|
+
|
377
|
+
%w(
|
378
|
+
alpha beta gamma delta epsilon zeta eta theta iota kappa lambda mu nu xi omicron pi rho sigma tau upsilon phi chi psi omega
|
379
|
+
).each do |a|
|
380
|
+
[a, a.capitalize].each do |b|
|
381
|
+
key = b.to_sym
|
382
|
+
value = "\\#{b}".latex!.to_latex_math
|
383
|
+
define_symbol_macro key, value
|
384
|
+
define_global_macro key, value
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
('a'..'z').each do |a|
|
389
|
+
[a, a.capitalize].each do |b|
|
390
|
+
key = b.to_sym
|
391
|
+
value = "#{b}".latex!.to_latex_math
|
392
|
+
define_symbol_macro key, value
|
393
|
+
define_global_macro key, value
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
397
|
+
|
398
|
+
# units
|
399
|
+
$_units = {}
|
400
|
+
|
401
|
+
def unit hash
|
402
|
+
$_units.update hash
|
403
|
+
end
|
404
|
+
|
405
|
+
class Symbol
|
406
|
+
def with_unit
|
407
|
+
raise "No unit defined for #{self}" unless $_units[self]
|
408
|
+
self * "(#{$_units[self])}"
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
|
413
|
+
|
357
414
|
# debug
|
358
415
|
def debug *args
|
359
416
|
args.each {|a| STDERR.puts a.inspect}
|
@@ -371,3 +428,10 @@ end
|
|
371
428
|
def radians x
|
372
429
|
x / 180.0 * Math::PI
|
373
430
|
end
|
431
|
+
|
432
|
+
|
433
|
+
# tikz
|
434
|
+
def tikz *libs
|
435
|
+
$_erbout << "\\usepackage{tikz}\n"
|
436
|
+
$_erbout << "\\usetikzlibrary{#{libs.join(",")}}\n" if libs.any?
|
437
|
+
end
|
data/lib/texlab/texlabfile.rb
CHANGED
data/texlab.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "texlab"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Bern\u{e1}t Kall\u{f3}"]
|
12
|
-
s.date = "2012-04-
|
12
|
+
s.date = "2012-04-09"
|
13
13
|
s.description = "texlab a toolkit based on erb that for creating documents and doing calculations at the same time. It is capable to output the proper number of significant digits, generate tables and plots using gnuplot. It has a simple DSL."
|
14
14
|
s.email = "kallo.bernat@gmail.com"
|
15
15
|
s.executables = ["texlab-compile"]
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |s|
|
|
32
32
|
"bin/texlab-compile.tex",
|
33
33
|
"bin/texlab-console",
|
34
34
|
"doc/readme.texlab",
|
35
|
-
"lib/texlab.rake",
|
36
35
|
"lib/texlab.rb",
|
37
36
|
"lib/texlab/boot.rb",
|
38
37
|
"lib/texlab/texlabfile.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: texlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-09 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake4latex
|
16
|
-
requirement: &
|
16
|
+
requirement: &87496040 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *87496040
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: plusminus
|
27
|
-
requirement: &
|
27
|
+
requirement: &87286830 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *87286830
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: easystats
|
38
|
-
requirement: &
|
38
|
+
requirement: &87286310 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *87286310
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: to_latex
|
49
|
-
requirement: &
|
49
|
+
requirement: &87285950 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *87285950
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: gnuplot
|
60
|
-
requirement: &
|
60
|
+
requirement: &87285600 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *87285600
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: latex
|
71
|
-
requirement: &
|
71
|
+
requirement: &87285230 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *87285230
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &87284890 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 2.8.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *87284890
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rdoc
|
93
|
-
requirement: &
|
93
|
+
requirement: &87284560 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '3.12'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *87284560
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: bundler
|
104
|
-
requirement: &
|
104
|
+
requirement: &87284290 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: 1.0.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *87284290
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: jeweler
|
115
|
-
requirement: &
|
115
|
+
requirement: &87283950 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,10 +120,10 @@ dependencies:
|
|
120
120
|
version: 1.8.3
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *87283950
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
125
|
name: rcov
|
126
|
-
requirement: &
|
126
|
+
requirement: &87283510 !ruby/object:Gem::Requirement
|
127
127
|
none: false
|
128
128
|
requirements:
|
129
129
|
- - ! '>='
|
@@ -131,7 +131,7 @@ dependencies:
|
|
131
131
|
version: '0'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
|
-
version_requirements: *
|
134
|
+
version_requirements: *87283510
|
135
135
|
description: texlab a toolkit based on erb that for creating documents and doing calculations
|
136
136
|
at the same time. It is capable to output the proper number of significant digits,
|
137
137
|
generate tables and plots using gnuplot. It has a simple DSL.
|
@@ -157,7 +157,6 @@ files:
|
|
157
157
|
- bin/texlab-compile.tex
|
158
158
|
- bin/texlab-console
|
159
159
|
- doc/readme.texlab
|
160
|
-
- lib/texlab.rake
|
161
160
|
- lib/texlab.rb
|
162
161
|
- lib/texlab/boot.rb
|
163
162
|
- lib/texlab/texlabfile.rb
|
@@ -181,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
180
|
version: '0'
|
182
181
|
segments:
|
183
182
|
- 0
|
184
|
-
hash:
|
183
|
+
hash: -421959251
|
185
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
185
|
none: false
|
187
186
|
requirements:
|