asciidoctor-latex 1.5.0.dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.adoc +22 -0
  3. data/README.adoc +213 -0
  4. data/Rakefile +55 -0
  5. data/bin/asciidoctor-latex +22 -0
  6. data/data/asciidoc_tex_macros.tex +42 -0
  7. data/data/preamble_article.tex +45 -0
  8. data/data/preamble_book.tex +44 -0
  9. data/lib/asciidoctor-latex.rb +1 -0
  10. data/lib/asciidoctor/latex.rb +8 -0
  11. data/lib/asciidoctor/latex/chem.rb +24 -0
  12. data/lib/asciidoctor/latex/click_block.rb +121 -0
  13. data/lib/asciidoctor/latex/converter.rb +358 -0
  14. data/lib/asciidoctor/latex/core_ext/colored_string.rb +35 -0
  15. data/lib/asciidoctor/latex/dollar.rb +28 -0
  16. data/lib/asciidoctor/latex/ent_to_uni.rb +17 -0
  17. data/lib/asciidoctor/latex/environment_block.rb +190 -0
  18. data/lib/asciidoctor/latex/inject_html.rb +49 -0
  19. data/lib/asciidoctor/latex/inline_macros.rb +20 -0
  20. data/lib/asciidoctor/latex/macro_insert.rb +49 -0
  21. data/lib/asciidoctor/latex/node_processors.rb +695 -0
  22. data/lib/asciidoctor/latex/prepend_processor.rb +36 -0
  23. data/lib/asciidoctor/latex/preprocess.rb +37 -0
  24. data/lib/asciidoctor/latex/tex_block.rb +108 -0
  25. data/lib/asciidoctor/latex/tex_postprocessor.rb +44 -0
  26. data/lib/asciidoctor/latex/tex_preprocessor.rb +65 -0
  27. data/lib/asciidoctor/latex/version.rb +5 -0
  28. data/manual.adoc +285 -0
  29. data/rake/cacert.pem +3894 -0
  30. data/rake/jdk_helper.rb +105 -0
  31. data/rake/tar-licence +19 -0
  32. data/rake/tar.rb +38 -0
  33. data/rspec/README.adoc +45 -0
  34. data/rspec/a.rb +79 -0
  35. data/rspec/b.rb +111 -0
  36. data/rspec/c.rb +121 -0
  37. data/rspec/data/tex1 +65 -0
  38. data/rspec/data/tex2 +5 -0
  39. data/rspec/data/tex2.expect +5 -0
  40. data/rspec/transform.rb +36 -0
  41. data/spec/README.adoc +45 -0
  42. data/spec/a.rb +79 -0
  43. data/spec/b.rb +111 -0
  44. data/spec/c.rb +121 -0
  45. data/spec/data/foo +1 -0
  46. data/spec/data/lorem +1 -0
  47. data/spec/data/tex1 +65 -0
  48. data/spec/data/tex2 +5 -0
  49. data/spec/data/tex2.expect +5 -0
  50. data/spec/transform.rb +36 -0
  51. data/test/examples/adoc/env.adoc +16 -0
  52. data/test/examples/adoc/eq.adoc +12 -0
  53. data/test/examples/adoc/zero.adoc +3 -0
  54. data/test/examples/asciidoc-html/block_open.adoc +17 -0
  55. data/test/examples/tex/env.tex +132 -0
  56. data/test/examples/tex/eq.tex +132 -0
  57. data/test/examples/tex/zero.tex +121 -0
  58. data/test/html_test.rb +8 -0
  59. data/test/latex_test.rb +8 -0
  60. data/test/test_helper.rb +4 -0
  61. data/test_jc/admonition.adoc +4 -0
  62. data/test_jc/click.adoc +7 -0
  63. data/test_jc/env.adoc +31 -0
  64. data/test_jc/example.adoc +17 -0
  65. data/test_jc/floating_title.adoc +15 -0
  66. data/test_jc/image.adoc +84 -0
  67. data/test_jc/images/frog.jpg +0 -0
  68. data/test_jc/images/red_frog.jpeg +0 -0
  69. data/test_jc/images/yellow_frog.jpeg +0 -0
  70. data/test_jc/listing.adoc +9 -0
  71. data/test_jc/lists.adoc +20 -0
  72. data/test_jc/math.adoc +10 -0
  73. data/test_jc/preamble.adoc +14 -0
  74. data/test_jc/section-numbered.adoc +9 -0
  75. data/test_jc/section.adoc +7 -0
  76. data/test_jc/sidebar.adoc +61 -0
  77. data/test_jc/verse.adoc +15 -0
  78. data/try-out/README.adoc +348 -0
  79. data/try-out/click.adoc +108 -0
  80. data/try-out/code.adoc +122 -0
  81. data/try-out/env.adoc +139 -0
  82. data/try-out/eq-latex.adoc +37 -0
  83. data/try-out/eq-stem.adoc +41 -0
  84. data/try-out/eqno-latex.adoc +120 -0
  85. data/try-out/math_article.adoc +138 -0
  86. data/try-out/pyth-stem.adoc +52 -0
  87. data/try-out/theorem-latex.adoc +50 -0
  88. data/try-out/xref-equations.adoc +28 -0
  89. metadata +210 -0
@@ -0,0 +1,108 @@
1
+ == Click blocks
2
+
3
+ {set:click_extras:include}
4
+
5
+
6
+ Click blocks are like `env`-blocks, except that
7
+ when you open a document, only the title,
8
+ not the body of the block, is displayed.
9
+ Click on the title to reveal the body;
10
+ clicking again will return the body
11
+ to its hidden sate. Click blocks
12
+ signal their presence by the blue
13
+ color of the title.
14
+
15
+ .Secret
16
+ [click.message]
17
+ --
18
+ The path to wisdom is written on no
19
+ secret map.
20
+ --
21
+
22
+ === Homework
23
+
24
+ Click blocks are useful for writing homework
25
+ problems and study aids.
26
+
27
+ [env.problem]
28
+ --
29
+ A 70 kg man had climbed onto a one-meter ledge
30
+ at a rock-climbing school. He was not careful,
31
+ and so he slipped and fell. How fast was he
32
+ going when he landed on the ground?
33
+ --
34
+
35
+ [click.hint]
36
+ --
37
+ Find his potential energy before he slipped.
38
+ That is the same as his kinetic energy
39
+ when he landed.
40
+ --
41
+
42
+ [click.solution]
43
+ --
44
+ The man's potential energy is $V = mgh$,
45
+ where $m$ is his mass, $g = 9.8$ is the acceleration
46
+ of gravity,ahd $h$ is the height (1 meter). All
47
+ units are standard international. One
48
+ finds that his potential energy is 686 Joules.
49
+ His kinetic energy is
50
+ \[
51
+ K = \frac{1}{2} mv^2
52
+ \]
53
+ One finds that $v = 4.4 m/sec$, or aout 15 km/hr.
54
+ --
55
+
56
+
57
+ [env.problem]
58
+ --
59
+ When the man fell, the apple that he had carefully set
60
+ on the ledge also fell. How fast was
61
+ it going when it hit hit the ground?
62
+ --
63
+
64
+
65
+
66
+ === Problem sets
67
+
68
+ Click blocks are useful for constructing problem sets.
69
+ Here we give some mathematics problems.
70
+
71
+
72
+ [env.problem]
73
+ --
74
+ Find the solutions to $2x +5y = 1$ and $7x - 3y = 30$.
75
+ --
76
+
77
+ [click.hint]
78
+ --
79
+ Use the first equation to solve for $y$. Substitute
80
+ into the second equation to get a equation in $x$ alone.
81
+ --
82
+
83
+ [click.advice]
84
+ --
85
+ If you work _slowly_ and _deliberately_, you can get
86
+ this problem right on the first try. Be sure to check your
87
+ answer.
88
+ --
89
+
90
+ [click.solution]
91
+ --
92
+ $x = \frac{153}{41}$ and $y = -\frac{53}{41}$
93
+ --
94
+
95
+ +++<br/>+++
96
+
97
+ [env.problem]
98
+ --
99
+ Find the area under the graph of $y = x^2$ between $x= 1$ and $x = 2$.
100
+ --
101
+
102
+ [click.solution]
103
+ --
104
+ \[
105
+ \int_1^2 x^2 dx = \left[ \frac{x^3}{3} \right]_1^2
106
+ = \frac{2^3}{3} - \frac{1^3}{3} = \frac{7}{3}
107
+ \]
108
+ --
data/try-out/code.adoc ADDED
@@ -0,0 +1,122 @@
1
+
2
+ _This section ilustrates the use of_ `[env.code]` _for
3
+ listing code, of the_ `[env.equation]` _block for numbered
4
+ equations,_ `[click.code]` _block for code listings
5
+ that can be clicked on to reveal more text, and
6
+ cross references to_ `[env]` blocks.
7
+
8
+ == On code and computing square roots
9
+
10
+ The problem of computing square roots was
11
+ solved in Mesopotamia are 1700 BCE. It is not
12
+ know for sure what the method was, but it is
13
+ likely the related to the one used in <<iter>>.
14
+
15
+
16
+ [env.code#iter]
17
+ --
18
+ def iter(f, a, n)
19
+ n.times do
20
+ a = f.call(a)
21
+ puts a
22
+ end
23
+ return a
24
+ end
25
+ --
26
+
27
+ The purpose of the program is to repeatedly apply a function
28
+ to an initial value, each time taking as input the
29
+ output of the previous step. Thus, if $a = 1$, $f(x) = 2x$, an
30
+ $n = 4$, we have the sequence $a = 1$, $f(1) = 2$, $f(2) = 4$,
31
+ $f(4) = 8$, and $f(8) = 16$. This is the sequence
32
+ \[
33
+ 1,\ 2,\ 4,\ 8,\ 16
34
+ \]
35
+ We comppute it using our program like this:
36
+ [env.code]
37
+ --
38
+ irb> $double = lambda { |x| 2*x) }
39
+
40
+ irb> iter($double, 1, 4)
41
+ --
42
+ Here is what we think the Babylonians did
43
+ to compute the square root of 2. Take an
44
+ initial guess for the square root, say,
45
+ $a = 1$. Divide it into 2. If you happened
46
+ to have guessed exaclty right, the quotient
47
+ would be the same as your guess. If you
48
+ guessed low, the quotient would be high.
49
+ If you guessed low, the quotient would
50
+ be high. So take the average of
51
+ $a$ and $2/a$ to get a better guess.
52
+ And let's repeat this process in order
53
+ to refine our guess still further.
54
+ Computing by hand (which is always
55
+ a good idea for starters) give the
56
+ sequence
57
+ \[
58
+ 1,\ \frac{3}{2},\ \frac{9}{8}
59
+ \]
60
+ But the work is beginnng to get tiresome, ad
61
+ so we run our program with $a = 1$ and $n = 1$
62
+ to get this (click on the blue text to reveal
63
+ what is hidden).
64
+
65
+ .Results
66
+ [click.code%numbered]
67
+ --
68
+ irb> iter $g, 1.0, 6
69
+ 1.5
70
+ 1.4166666666666665
71
+ 1.4142156862745097
72
+ 1.4142135623746899
73
+ 1.414213562373095
74
+ 1.414213562373095
75
+ => 1.414213562373095
76
+ --
77
+
78
+ You can see that the sequence converges
79
+ very rapidly to the square root of two:
80
+ [env.equation]
81
+ --
82
+ \lim_{n\to\infty} a_n = \sqrt 2
83
+ --
84
+ This was good for the Babylonian
85
+ scribes, who did all of their
86
+ computations in base 60 with
87
+ a stylus and a clay tablet!
88
+ The "Babylonian method" is special case
89
+ of Newton's metod for computing roots
90
+ of an equation $f(x) = 0$. The idea is
91
+ to take an initial guess $a_0$, as above,
92
+ then make it better. We do this by
93
+ constructing the tangent line to the
94
+ graph if $f$ at $x = a_0$, then finding
95
+ the point $a_1$ where the tangent line
96
+ at $(a_0,f(a_0))$ intersects the $x$-axis.
97
+ Using calculus to compute the slope
98
+ of the tangent line, one obtains
99
+ the function below for computing
100
+ $\sqrt a$.
101
+ [env.equation]
102
+ --
103
+ g(x) = \frac{1}{2} \left( x + \frac{a}{x} \right)
104
+ --
105
+ Iteration of this function, by hand, using
106
+ <<iter>>, or by some other merhod,
107
+ produces sequences which usually converge
108
+ verty rapidly to a root.
109
+
110
+ [env.exercise]
111
+ --
112
+ Consider the function $g(x)$ above.
113
+ What are the solutions of $g(x) = x$?
114
+ --
115
+
116
+ [click.remark]
117
+ --
118
+ A point $p$ that satifies $g(p) = p$
119
+ is called a *fixed point*. Iteration
120
+ of a function on such point results
121
+ in the sequence $p, p, p, \ldots$.
122
+ --
data/try-out/env.adoc ADDED
@@ -0,0 +1,139 @@
1
+ :numbered:
2
+
3
+ == Using the env block
4
+
5
+
6
+ The `env` block gives a very general way of creating
7
+ LaTeX-style environments with Asciidoctor. They
8
+ will render properly in all output formats, e.g.,
9
+ HTML and LaTeX. We can
10
+ make definitions with `[env.definition]` like this
11
+
12
+ ----
13
+ [env.definition#def-point]
14
+ --
15
+ A point is that which has no breadth.
16
+ --
17
+ ----
18
+
19
+ It is rendered like this:
20
+
21
+ [env.definition#def-point]
22
+ --
23
+ A point is that which has no breadth.
24
+ --
25
+
26
+ Here is another defnition. Note that it is numbered
27
+ automatically.
28
+
29
+ [env.definition]
30
+ --
31
+ A line is the path of shortest length between two points.
32
+ --
33
+
34
+ We can create `env`-blocks at will: `[env.theorem]`, `[env.lemma]`, `[env.corollary]`,
35
+ etc. Asciidoctor does not have to be informed about them
36
+ in advance if we are producing HTML. If we want a joke environment,
37
+ we can have it:
38
+
39
+
40
+ [env.joke]
41
+ --
42
+ An engineer, a mathematician, and a philosopher met
43
+ at a bar for a drink. After a few beers, talk
44
+ turned to the question of how best to understand
45
+ the world ... (to be continued)
46
+ --
47
+
48
+ [env.objection]
49
+ --
50
+ Your honor, my client could not have committed the
51
+ crime of which he is accused because he was
52
+ confined to the state penitentary at the time
53
+ that it occurred. If it please the court, ...
54
+ --
55
+
56
+ == Variations
57
+
58
+ A an `env`-block can optionally take a title:
59
+
60
+ .Inadmissible testimony
61
+ [env.objection]
62
+ --
63
+ Your honor, that testimony cannot be
64
+ heard in this courtroom because it
65
+ was obtained under duress and without
66
+ informing my client of his rights.
67
+ --
68
+
69
+ Here is how it is done:
70
+
71
+ ----
72
+ .Inadmissible testimony
73
+ [env.objection]
74
+ --
75
+ Your honor, that testimony cannot be
76
+ heard in this courtroom because it
77
+ was obtained under duress and without
78
+ informing my client of his rights.
79
+ --
80
+ ----
81
+
82
+
83
+ In addition, numbering, which is on by default,
84
+ can be turned off on a per-item basis:
85
+
86
+ .Improper procedure
87
+ [env.objection%no-number]
88
+ --
89
+ Your honor, the physical evidence
90
+ was not secured and was handled sloppily.
91
+ We cannot be sure tha the items which
92
+ the prosecution wishes to present here
93
+ have any association with my client
94
+ whatsoever.
95
+ --
96
+
97
+ The no-number option also applies
98
+ when there is no title.
99
+
100
+ [env.objection%no-number]
101
+ --
102
+ Your honor, the defense is speechless.
103
+ The prosecution continues to present
104
+ evidence which is inadmissbile. The
105
+ defense calls for a consultation
106
+ _in camera_.
107
+ --
108
+
109
+ == Cross-references
110
+
111
+ I refer to <<def-point>>
112
+
113
+ == Customizing LaTeX output for env blocks
114
+
115
+ If the output is LaTeX, the situation is slightly different.
116
+ As Asciidoctor converts a file, say `foo.adoc`, it generates
117
+ a list of the environments it encounters
118
+ and records them in a file `newEnvironments.tex`. It
119
+ has entries like this:
120
+ ----
121
+ \newtheorem{joke}{Joke}
122
+ \newtheorem{objection}{Objection}
123
+ ----
124
+ It also adds the command
125
+ ----
126
+ \input newEnvironments.tex
127
+ ----
128
+ to the preamble of `foo.tex`. Thus,
129
+ when you run `xelatex foo.tex`,
130
+ those environments will be defined
131
+ and their occurence in the file
132
+ `foo.tex` will not generate an
133
+ error. You can modify those
134
+ definitions and put them
135
+ in a file named
136
+ `myEnvironments.tex`. It will be used instead of
137
+ `newEnvironments.tex`. Nonethless,
138
+ `newEnvironments.tex`. will be
139
+ regnerated each time `asciidoctor` is run.
@@ -0,0 +1,37 @@
1
+ == Some Equations
2
+
3
+
4
+ === Number Theory
5
+
6
+ The equation
7
+ $a^2 + b^2 = c^2$ has infinitely many
8
+ non-proportional integer solutions.
9
+ The integer solutions of the equation
10
+ \[
11
+ a^3 + b^3 = c^3
12
+ \]
13
+ are trivial: at least one entry is
14
+ zero and the others are "obvious"
15
+
16
+ === Calculus
17
+
18
+ A definite integral:
19
+ \[
20
+ \int_0^1 x^n dx = \frac{1}{n}
21
+ \]
22
+
23
+ The fundamental theorem of calculus:
24
+ \[
25
+ \frac{d}{dx} \int_a^x f(t) dt = f(x)
26
+ \]
27
+
28
+ === Linear algebra
29
+
30
+ A matrix:
31
+ \[
32
+ M = \left[
33
+ \begin{array}{ c c }
34
+ 1 & 2 \\
35
+ 3 & 4
36
+ \end{array} \right]
37
+ \]
@@ -0,0 +1,41 @@
1
+ == Some Equations
2
+
3
+
4
+ === Number Theory
5
+
6
+ The equation
7
+ stem:[a^2 + b^2 = c^2] has infinitely many
8
+ non-proportional integer solutions.
9
+ The integer solutions of the equation
10
+ [stem]
11
+ ++++
12
+ a^3 + b^3 = c^3
13
+ ++++
14
+ are trivial: at least one entry is
15
+ zero and the others are "obvious"
16
+
17
+ === Calculus
18
+
19
+ A definite integral:
20
+ [stem]
21
+ ++++
22
+ \int_0^1 x^n dx = \frac{1}{n}
23
+ ++++
24
+
25
+ The fundamental theorem of calculus:
26
+ [stem]
27
+ ++++
28
+ \frac{d}{dx} \int_a^x f(t) dt = f(x)
29
+ ++++
30
+
31
+ === Linear algebra
32
+
33
+ A matrix:
34
+ [stem]
35
+ ++++
36
+ M = \left[
37
+ \begin{array}{ c c }
38
+ 1 & 2 \\
39
+ 3 & 4
40
+ \end{array} \right]
41
+ ++++