rake4latex 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/readme.html ADDED
@@ -0,0 +1,236 @@
1
+ <!--
2
+
3
+ Build by C:/Program Files/ruby/lib/ruby/gems/1.8/gems/docgenerator-1.2.0/./lib/docgenerator/document.rb
4
+ Dir: C:/usr/Script/rake4latex
5
+ Creator: rakefile_rake4latex.rb
6
+ Target: readme.html
7
+ 2010/01/03 21:19:00
8
+
9
+ Generation-Info-End
10
+ -->
11
+ <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
12
+ <html>
13
+ <head ></head>
14
+ <body ><h1 >rake4latex: TeX-Build-Tool</h1>
15
+ <h2 >Introduction</h2>
16
+ <p >
17
+ This file contains definitions to build a rakefile for LaTeX-documents.
18
+ </p>
19
+ <p >
20
+ A not-so minimal rakefile looks like this:
21
+ </p>
22
+ <pre>
23
+ require 'rake4latex'
24
+ #Needed for some actions without a previous TeX-call
25
+ task :basefile =&gt; 'testdocument.tex'
26
+ #We want to build a PDF
27
+ file 'testdocument.pdf' =&gt; 'testdocument.tex'
28
+
29
+ #Force the compilation
30
+ task :touch =&gt; 'testdocument.tex'
31
+
32
+ #Define the default tasks
33
+ task :default =&gt; :touch
34
+ task :default =&gt; 'testdocument.pdf'
35
+ task :default =&gt; :statistic
36
+ task :default =&gt; :clean
37
+
38
+ #Make the rakefile self-executable
39
+ if $0 == __FILE__
40
+ app = Rake.application
41
+ app[:default].invoke
42
+ end
43
+ </pre>
44
+ <p >
45
+ You can generate this template with:
46
+ </p>
47
+ <pre>
48
+ require 'rake4latex'
49
+ puts Rake4LaTeX.template( [basename] )
50
+ </pre>
51
+ <h2 >Multiple runs</h2>
52
+ <p >
53
+ One of the problems with writing a Makefile for LaTeX is that often latex
54
+ needs to be run more than once on the same file, before obtaining the final
55
+ output. Moreover, every LaTeX package may require other runs basing on different
56
+ conditions and maybe even requiring some other program to be run between latex
57
+ invocations.
58
+ </p>
59
+ <p >
60
+ Makefile normally expect a defined sequence of prerequisites. Prerequisites are known before the action takes care. Some dependecies of (La)TeX-documents creates ther prerequisites after the (La)TeX-run (e.g. new index entries).
61
+ </p>
62
+ <p >
63
+ The approach followed here is to define "Post-Prerequisites". The virtual target :latex_dependecies contains all this "Post-Prerequisites". After a TeX-run, each Post-Prerequisites is checked. For each post-prerequisites you must define a rule (in the following
64
+ called postprereq.
65
+ </p>
66
+ <p >
67
+ The prerequisites of postprereq are checked for changes. To detect changes, the Hash-Code of the prerequisite-files before and
68
+ after the TeX-run are compared (the comparison of the time stamp makes no sense, TeX always(*) recreate the files).
69
+ </p>
70
+ <p >
71
+ <small>*) Forget the \nofiles-command</small>
72
+ </p>
73
+ <p >
74
+ See the examples-section hot to define your own custom action.
75
+ </p>
76
+ <p >
77
+ To avoid problems of endless loops, a there's a maximum number of runs,
78
+ which is 5 by default. The user can change it in the runner.
79
+ </p>
80
+ <h2 >Dependencies</h2>
81
+ <p >
82
+ You must define your dependencies your own (but there is a help to do so,
83
+ see next next section)
84
+ </p>
85
+ <p >
86
+ Example:
87
+ </p>
88
+ <pre>
89
+ file 'testdocument.dvi' =&gt; ['testdocument.tex', 'testincludes/testinclude1.tex']
90
+ </pre>
91
+ <h3 >Determine Dependecies: LaTeXDependencies.get_dependecies( )</h3>
92
+ <p >
93
+ You can automatically compute dependencies for the latex task: LaTeXDependencies.new(filename).get_dependecies( *options ) Options may be:
94
+ </p>
95
+ <ul >
96
+ <li > :inputs:<br />
97
+ The input file (the one which is passed to latex) is read, and the
98
+ arguments of the <tt>\includeonly</tt>, <tt>\include</tt> and <tt>\input</tt> latex
99
+ commands are extracted. Each of this these files is scanned again for dependecies. <br />
100
+ The result is a nested array with all dependecies. </li>
101
+ <li > :flat:<br />
102
+ The (nested) result is flatted and double entries are deleted. </li>
103
+ </ul>
104
+ <p >
105
+ You can use it already direct in your dependecies definition:
106
+ </p>
107
+ <pre>
108
+ file 'testdocument.dvi' =&gt; LaTeXDependencies.new('testdocument.tex').get_dependecies( *options )
109
+ </pre>
110
+ <h3 >Dependecies for BibTeX</h3>
111
+ <p >
112
+ BibTeX depends on two files:
113
+ </p>
114
+ <ul >
115
+ <li > aux file with the list of the cites. </li>
116
+ <li > bib-file(s) with the data of the literature. </li>
117
+ </ul>
118
+ <p >
119
+ You can define the dependecies of bib-file in your rakefile:
120
+ </p>
121
+ <pre>
122
+ file 'testdocument.pdf' =&gt; 'testdocument.bib'
123
+ file 'testdocument.bbl' =&gt; 'testdocument.bib'
124
+ </pre>
125
+ <p >
126
+ You need both definitions. The pdf-dependecy is needed to start a new TeX-run, The bbl-dependecy is needed to start a new BibTeX-run.
127
+ </p>
128
+ <h2 >Supported tools and packages</h2>
129
+ <h3 >Supported tools</h3>
130
+ <p >
131
+ The following tools are supported by rake4latex:
132
+ </p>
133
+ <ul >
134
+ <li > Makeindex with makeidx.sty </li>
135
+ <li > BibTeX </li>
136
+ </ul>
137
+ <h3 >Supported (checked) packages</h3>
138
+ <p >
139
+ The rake process to generate the document is independent of any package. But some packages requires additional TeX-runs. The following packages are tested and work fine:
140
+ </p>
141
+ <ul >
142
+ <li > minitoc </li>
143
+ <li > longtable </li>
144
+ <li > supertabular </li>
145
+ <li > splitindex (splitindex is replaced by internal routines) </li>
146
+ </ul>
147
+ <p >
148
+ Untested packages:
149
+ </p>
150
+ <ul >
151
+ <li > glossary </li>
152
+ <li > multiind/index (not planned to check, please use splitindex or inform me
153
+ about your need) </li>
154
+ </ul>
155
+ <h2 >Adding new tasks</h2>
156
+ <h3 >Normal tasks</h3>
157
+ <p >
158
+ Task to generate pictures or other stuff needed to build your LaTeX project can be added like normal rake-tasks.
159
+ </p>
160
+ <h3 >TeX-related tasks</h3>
161
+ <p >
162
+ Some task must be executed after a TeX-run. This tasks must be created with <tt>tex_postrule</tt> instead of the rake-method <tt>rule</tt>.
163
+ </p>
164
+ <p >
165
+ The tasks for makeindex and bibTeX are already defined.
166
+ </p>
167
+ <h4 >Example makeindex</h4>
168
+ <p >
169
+ An example for this tasks is makeindex. After a TeX-run you must check, if there are are new or changed index entries.
170
+ </p>
171
+ <p >
172
+ The makeindex-task looks like this:
173
+ </p>
174
+ <pre>
175
+ desc "Call Makeindex"
176
+ tex_postrule '.ind' =&gt; '.idx' do |t|
177
+ sh "makeindex #{t.source}"
178
+ end
179
+ </pre>
180
+ <p >
181
+ That's it to get an index.
182
+ </p>
183
+ <p >
184
+ After a TeX-run, the prerequisites of rule '.ind' is checked for changes (Hash-Code of the idx-file before and after the TeX-Run). If there is a change, the rule is called. And if the .ind-file changed, an additional TeX-call is forced.
185
+ </p>
186
+ <h4 >Example BibTeX</h4>
187
+ <p >
188
+ BibTeX is a bit more complicated:
189
+ </p>
190
+ <pre>
191
+ tex_postrule '.bbl' =&gt; '.aux' do |t, args |
192
+ sh "bibtex #{t.source}"
193
+ end
194
+ </pre>
195
+ <p >
196
+ With this rule, BibTeX is called every times the aux-file changed (if we use BibTeX or not). We need a modified pre-check, if the BibTeX-call is necessary:
197
+ </p>
198
+ <pre>
199
+ tex_postrule_check '.bbl' do |args|
200
+ auxfile = args[:task].name.ext('aux')
201
+ File.exist?(auxfile) and #there is a aux-file
202
+ ( args[:checksums][auxfile] == :changed ) and #the aux-file changed
203
+ ( necessary and File.read(auxfile) =~ /bibdata/ )#and we use bibtex
204
+ end
205
+ </pre>
206
+ <p >
207
+ See also section 'Multiple runs'
208
+ </p>
209
+ <h2 >Known Bugs and Problems</h2>
210
+ <ul >
211
+ <li >Only pdflatex/xelatex/lualatex/latex to create the target, no ps-files, no ps2pdf. <ul >
212
+ <li >Intended for the next release </li>
213
+ </ul>
214
+ </li>
215
+ <li > Two runs for new documents, when only one is needed.<br />
216
+ After the first run, the aux-file is created, so rake4latex detect a reason to rerun. Solution would be to make a log-file analyse. <ul >
217
+ <li > No plan to solve it. Not a big problem, and why you need a rakefile for such simple
218
+ tex-files? </li>
219
+ </ul>
220
+ </li>
221
+ <li > No usage of kpsewhich<br />
222
+ LaTeXDependencies#get_dependecies checks dependecies only relative to the file location. kpsewhich is not used. <ul >
223
+ <li > Would be nice escpecially for BibTeX and scan for \bibliography{xxx} </li>
224
+ <li > Low priority </li>
225
+ </ul>
226
+ </li>
227
+ </ul>
228
+ <h2 >Version History</h2>
229
+ <p >
230
+ 0.0.1 2010-01-03
231
+ </p>
232
+ <ul >
233
+ <li > First release </li>
234
+ </ul>
235
+ </body>
236
+ </html>
data/readme.txt ADDED
@@ -0,0 +1,186 @@
1
+
2
+
3
+ rake4latex: TeX-Build-Tool
4
+ ------------------------------
5
+
6
+ Introduction
7
+ ------------------------------
8
+
9
+ This file contains definitions to build a rakefile for LaTeX-documents.
10
+
11
+ A not-so minimal rakefile looks like this:
12
+ require 'rake4latex'
13
+ #Needed for some actions without a previous TeX-call
14
+ task :basefile => 'testdocument.tex'
15
+ #We want to build a PDF
16
+ file 'testdocument.pdf' => 'testdocument.tex'
17
+
18
+ #Force the compilation
19
+ task :touch => 'testdocument.tex'
20
+
21
+ #Define the default tasks
22
+ task :default => :touch
23
+ task :default => 'testdocument.pdf'
24
+ task :default => :statistic
25
+ task :default => :clean
26
+
27
+ #Make the rakefile self-executable
28
+ if $0 == __FILE__
29
+ app = Rake.application
30
+ app[:default].invoke
31
+ end
32
+
33
+ You can generate this template with:
34
+ require 'rake4latex'
35
+ puts Rake4LaTeX.template( [basename] )
36
+
37
+ Multiple runs
38
+ ------------------------------
39
+
40
+ One of the problems with writing a Makefile for LaTeX is that often latex
41
+ needs to be run more than once on the same file, before obtaining the final
42
+ output. Moreover, every LaTeX package may require other runs basing on different
43
+ conditions and maybe even requiring some other program to be run between latex
44
+ invocations.
45
+
46
+ Makefile normally expect a defined sequence of prerequisites. Prerequisites are known before the action takes care. Some dependecies of (La)TeX-documents creates ther prerequisites after the (La)TeX-run (e.g. new index entries).
47
+
48
+ The approach followed here is to define "Post-Prerequisites". The virtual target :latex_dependecies contains all this "Post-Prerequisites". After a TeX-run, each Post-Prerequisites is checked. For each post-prerequisites you must define a rule (in the following
49
+ called postprereq.
50
+
51
+ The prerequisites of postprereq are checked for changes. To detect changes, the Hash-Code of the prerequisite-files before and
52
+ after the TeX-run are compared (the comparison of the time stamp makes no sense, TeX always(*) recreate the files).
53
+
54
+ <small>*) Forget the \nofiles-command</small>
55
+
56
+ See the examples-section hot to define your own custom action.
57
+
58
+ To avoid problems of endless loops, a there's a maximum number of runs,
59
+ which is 5 by default. The user can change it in the runner.
60
+
61
+ Dependencies
62
+ ------------------------------
63
+
64
+ You must define your dependencies your own (but there is a help to do so,
65
+ see next next section)
66
+
67
+ Example:
68
+ file 'testdocument.dvi' => ['testdocument.tex', 'testincludes/testinclude1.tex']
69
+
70
+ Determine Dependecies: LaTeXDependencies.get_dependecies( )
71
+ ------------------------------
72
+
73
+ You can automatically compute dependencies for the latex task: LaTeXDependencies.new(filename).get_dependecies( *options ) Options may be:
74
+ - :inputs:
75
+ The input file (the one which is passed to latex) is read, and the
76
+ arguments of the <tt>\includeonly</tt>, <tt>\include</tt> and <tt>\input</tt> latex
77
+ commands are extracted. Each of this these files is scanned again for dependecies.
78
+ The result is a nested array with all dependecies.
79
+ - :flat:
80
+ The (nested) result is flatted and double entries are deleted.
81
+
82
+ You can use it already direct in your dependecies definition:
83
+ file 'testdocument.dvi' => LaTeXDependencies.new('testdocument.tex').get_dependecies( *options )
84
+
85
+ Dependecies for BibTeX
86
+ ------------------------------
87
+
88
+ BibTeX depends on two files:
89
+ - aux file with the list of the cites.
90
+ - bib-file(s) with the data of the literature.
91
+
92
+ You can define the dependecies of bib-file in your rakefile:
93
+ file 'testdocument.pdf' => 'testdocument.bib'
94
+ file 'testdocument.bbl' => 'testdocument.bib'
95
+
96
+ You need both definitions. The pdf-dependecy is needed to start a new TeX-run, The bbl-dependecy is needed to start a new BibTeX-run.
97
+
98
+ Supported tools and packages
99
+ ------------------------------
100
+
101
+ Supported tools
102
+ ------------------------------
103
+
104
+ The following tools are supported by rake4latex:
105
+ - Makeindex with makeidx.sty
106
+ - BibTeX
107
+
108
+ Supported (checked) packages
109
+ ------------------------------
110
+
111
+ The rake process to generate the document is independent of any package. But some packages requires additional TeX-runs. The following packages are tested and work fine:
112
+ - minitoc
113
+ - longtable
114
+ - supertabular
115
+ - splitindex (splitindex is replaced by internal routines)
116
+
117
+ Untested packages:
118
+ - glossary
119
+ - multiind/index (not planned to check, please use splitindex or inform me
120
+ about your need)
121
+
122
+ Adding new tasks
123
+ ------------------------------
124
+
125
+ Normal tasks
126
+ ------------------------------
127
+
128
+ Task to generate pictures or other stuff needed to build your LaTeX project can be added like normal rake-tasks.
129
+
130
+ TeX-related tasks
131
+ ------------------------------
132
+
133
+ Some task must be executed after a TeX-run. This tasks must be created with <tt>tex_postrule</tt> instead of the rake-method <tt>rule</tt>.
134
+
135
+ The tasks for makeindex and bibTeX are already defined.
136
+
137
+ Example makeindex
138
+ ------------------------------
139
+
140
+ An example for this tasks is makeindex. After a TeX-run you must check, if there are are new or changed index entries.
141
+
142
+ The makeindex-task looks like this:
143
+ desc "Call Makeindex"
144
+ tex_postrule '.ind' => '.idx' do |t|
145
+ sh "makeindex #{t.source}"
146
+ end
147
+
148
+ That's it to get an index.
149
+
150
+ After a TeX-run, the prerequisites of rule '.ind' is checked for changes (Hash-Code of the idx-file before and after the TeX-Run). If there is a change, the rule is called. And if the .ind-file changed, an additional TeX-call is forced.
151
+
152
+ Example BibTeX
153
+ ------------------------------
154
+
155
+ BibTeX is a bit more complicated:
156
+ tex_postrule '.bbl' => '.aux' do |t, args |
157
+ sh "bibtex #{t.source}"
158
+ end
159
+
160
+ With this rule, BibTeX is called every times the aux-file changed (if we use BibTeX or not). We need a modified pre-check, if the BibTeX-call is necessary:
161
+ tex_postrule_check '.bbl' do |args|
162
+ auxfile = args[:task].name.ext('aux')
163
+ File.exist?(auxfile) and #there is a aux-file
164
+ ( args[:checksums][auxfile] == :changed ) and #the aux-file changed
165
+ ( necessary and File.read(auxfile) =~ /bibdata/ )#and we use bibtex
166
+ end
167
+
168
+ See also section 'Multiple runs'
169
+
170
+ Known Bugs and Problems
171
+ ------------------------------
172
+
173
+ - Only pdflatex/xelatex/lualatex/latex to create the target, no ps-files, no ps2pdf. - Intended for the next release
174
+ - Two runs for new documents, when only one is needed.
175
+ After the first run, the aux-file is created, so rake4latex detect a reason to rerun. Solution would be to make a log-file analyse. - No plan to solve it. Not a big problem, and why you need a rakefile for such simple
176
+ tex-files?
177
+ - No usage of kpsewhich
178
+ LaTeXDependencies#get_dependecies checks dependecies only relative to the file location. kpsewhich is not used. - Would be nice escpecially for BibTeX and scan for \bibliography{xxx}
179
+ - Low priority
180
+
181
+ Version History
182
+ ------------------------------
183
+
184
+ 0.0.1 2010-01-03
185
+ - First release
186
+
@@ -0,0 +1,59 @@
1
+ #
2
+ #Test BibTeX
3
+ #
4
+ #Braucht 3 Durchl�ufe
5
+ # 1 - erzeugt aux-datei (bibtex l�uft leer mit)
6
+ # 2 - aux-file enth�lt cite, bibtex l�uft mit.
7
+ # 3 - tex verwendet daten
8
+ #
9
+ #
10
+ Dir.chdir('../../lib'){ require 'rake4latex'}
11
+
12
+ deps = [
13
+ 'testdocument.tex',
14
+ ]
15
+
16
+ #Aditional dependecy to recognize bib-changes
17
+ deps << 'testdocument.bib'
18
+ file 'testdocument.bbl' => 'testdocument.bib'
19
+
20
+
21
+ file 'testdocument.dvi' => deps
22
+ file 'testdocument.pdf' => deps
23
+
24
+ #
25
+
26
+ #~ file 'testdocument.dvi' => LaTeXRunner.find_included_files( 'testdocument.tex' ).flatten.uniq
27
+
28
+ task :basefile => 'testdocument.tex'
29
+ task :touch => 'testdocument.tex' ##Zeitstempel anpassen/Kompilation erzwingen
30
+
31
+ task :default => :touch
32
+ #~ task :default => 'testdocument.dvi'
33
+ task :default => 'testdocument.pdf'
34
+ task :default => :clean
35
+
36
+ #~ task :clean do
37
+ #~ puts CLEAN.inspect
38
+ #~ puts CLOBBER.inspect
39
+ #~ end
40
+
41
+ desc "Testtask for Unittest"
42
+ task :test => [ :touch, 'testdocument.pdf' ]
43
+ desc "Check if bib-change restarts the TeX-process"
44
+ task :test_bib => [ :touch_bib, 'testdocument.pdf' ]
45
+
46
+ task :touch_bib do
47
+ FileUtils.touch('testdocument.bib')
48
+ end
49
+
50
+ if $0 == __FILE__
51
+ app = Rake.application
52
+ #~ app.set_latexrunner_default(:maxruns, 1)
53
+ #~ app.set_latexrunner_default(:loglevel, Log4r::DEBUG)
54
+ #~ app[:default].invoke
55
+
56
+ #~ app[:clean].invoke
57
+ #~ app[:test].invoke
58
+ app[:test_bib].invoke
59
+ end