galaaz 2.1.8 → 2.1.9

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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -0
  3. data/Rakefile +20 -2
  4. data/bin/check_gemfile_lock_version +46 -0
  5. data/bin/release_bump +26 -0
  6. data/blogs/README.md +4 -0
  7. data/blogs/galaaz_2_0/galaaz_2_0.Rmd +385 -0
  8. data/blogs/galaaz_2_0/galaaz_2_0.md +409 -0
  9. data/blogs/galaaz_2_0/galaaz_2_0.tex +756 -0
  10. data/blogs/galaaz_2_0/images/galaaz-header.png +0 -0
  11. data/blogs/galaaz_2_0/images/galaaz-lockup-stacked.png +0 -0
  12. data/blogs/galaaz_ggplot/galaaz_ggplot.Rmd +14 -1
  13. data/blogs/galaaz_ggplot/galaaz_ggplot.md +123 -103
  14. data/blogs/galaaz_ggplot/galaaz_ggplot.tex +60 -23
  15. data/blogs/galaaz_ggplot/images/galaaz-lockup-stacked.png +0 -0
  16. data/blogs/gknit/gknit.Rmd +16 -1
  17. data/blogs/gknit/gknit.md +13 -1
  18. data/blogs/gknit/gknit.tex +64 -23
  19. data/blogs/gknit/gknit_files/figure-html/bubble-1.png +0 -0
  20. data/blogs/gknit/gknit_files/figure-html/diverging_bar.png +0 -0
  21. data/blogs/gknit/gknit_files/figure-latex/bubble-1.png +0 -0
  22. data/blogs/gknit/images/galaaz-lockup-stacked.png +0 -0
  23. data/blogs/manual/images/galaaz-lockup-stacked.png +0 -0
  24. data/blogs/manual/manual.Rmd +32 -11
  25. data/blogs/manual/manual.md +30 -23
  26. data/blogs/manual/manual.tex +88 -66
  27. data/blogs/manual/manual_files/figure-html/bubble-1.png +0 -0
  28. data/blogs/manual/manual_files/figure-latex/bubble-1.png +0 -0
  29. data/blogs/nse_dplyr/images/galaaz-lockup-stacked.png +0 -0
  30. data/blogs/nse_dplyr/nse_dplyr.Rmd +14 -1
  31. data/blogs/nse_dplyr/nse_dplyr.md +697 -649
  32. data/blogs/nse_dplyr/nse_dplyr.tex +61 -24
  33. data/blogs/oh_my/images/galaaz-lockup-stacked.png +0 -0
  34. data/blogs/oh_my/oh_my.Rmd +14 -1
  35. data/blogs/oh_my/oh_my.md +36 -26
  36. data/blogs/oh_my/oh_my.tex +95 -58
  37. data/blogs/r_on_rails_ledger/images/00_portfolio_page.png +0 -0
  38. data/blogs/r_on_rails_ledger/images/01_results_panel.png +0 -0
  39. data/blogs/r_on_rails_ledger/images/02_density_tail_risk.png +0 -0
  40. data/blogs/r_on_rails_ledger/images/03_mc_cone.png +0 -0
  41. data/blogs/r_on_rails_ledger/images/04_rolling_var.png +0 -0
  42. data/blogs/r_on_rails_ledger/images/galaaz-lockup-stacked.png +0 -0
  43. data/blogs/r_on_rails_ledger/r_on_rails_ledger.Rmd +354 -0
  44. data/blogs/r_on_rails_ledger/r_on_rails_ledger.md +365 -0
  45. data/blogs/r_on_rails_ledger/r_on_rails_ledger.tex +670 -0
  46. data/blogs/ruby_plot/images/galaaz-lockup-stacked.png +0 -0
  47. data/blogs/ruby_plot/ruby_plot.Rmd +14 -1
  48. data/blogs/ruby_plot/ruby_plot.md +11 -1
  49. data/blogs/ruby_plot/ruby_plot.tex +60 -23
  50. data/blogs/ruby_plot/ruby_plot_files/figure-html/facets_with_jitter.png +0 -0
  51. data/blogs/ruby_plot/ruby_plot_files/figure-html/final_violin_plot.png +0 -0
  52. data/blogs/ruby_plot/ruby_plot_files/figure-html/violin_with_jitter.png +0 -0
  53. data/blogs/ruby_plot/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  54. data/blogs/ruby_plot/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  55. data/blogs/ruby_plot/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  56. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/facets_with_jitter.png +0 -0
  57. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/final_violin_plot.png +0 -0
  58. data/blogs/ruby_plot/ruby_plot_files/ruby_plot_files/figure-latex/violin_with_jitter.png +0 -0
  59. data/lib/galaaz/cli.rb +47 -3
  60. data/logos/icon-font/README.md +27 -0
  61. data/logos/icon-font/build_font.py +130 -0
  62. data/logos/icon-font/galaaz-mark.svg +34 -0
  63. data/script/omarchy/README.md +8 -1
  64. data/script/omarchy/fonts/galaaz.ttf +0 -0
  65. data/script/omarchy/install-galaaz.sh +8 -1
  66. data/script/omarchy/omarchy-menu.jsonc +21 -9
  67. data/sty/galaaz-header.png +0 -0
  68. data/sty/galaaz-headers-from-p3.tex +4 -0
  69. data/sty/galaaz.sty +54 -23
  70. data/version.rb +1 -1
  71. metadata +30 -9
  72. data/blogs/galaaz_ggplot/galaaz_ggplot.log +0 -745
  73. data/blogs/gknit/gknit_files/gknit_files/figure-latex/bubble-1.png +0 -0
  74. data/blogs/manual/manual.log +0 -1530
  75. data/blogs/manual/manual_files/manual_files/figure-latex/bubble-1.png +0 -0
  76. data/blogs/nse_dplyr/nse_dplyr.log +0 -824
  77. data/blogs/oh_my/oh_my.log +0 -974
  78. data/blogs/ruby_plot/ruby_plot.log +0 -887
@@ -8,9 +8,17 @@ output:
8
8
  html_document:
9
9
  self_contained: true
10
10
  keep_md: true
11
+ toc: true
12
+ toc_float: true
13
+ toc_depth: 2
14
+ number_sections: true
15
+ includes:
16
+ before_body: _logo_before_body.html
11
17
  pdf_document:
12
18
  includes:
13
- in_header: "../../sty/galaaz.sty"
19
+ in_header:
20
+ - "../../sty/galaaz.sty"
21
+ - "../../sty/galaaz-headers-from-p3.tex"
14
22
  keep_tex: yes
15
23
  number_sections: yes
16
24
  toc: true
@@ -25,6 +33,11 @@ fontsize: 11pt
25
33
  options(width = 70)
26
34
  ```
27
35
 
36
+ ```{r brand_logo, echo=FALSE, fig.align='center', out.width='45%', eval=knitr::is_latex_output()}
37
+ # PDF only — HTML uses _logo_before_body.html (above the TOC).
38
+ knitr::include_graphics("images/galaaz-lockup-stacked.png")
39
+ ```
40
+
28
41
  # Introduction
29
42
 
30
43
  Galaaz is a system for tightly coupling Ruby and R. Ruby is a powerful language, with
@@ -1,37 +1,65 @@
1
+ ---
2
+ title: "Ruby Plotting with Galaaz"
3
+ subtitle: "An example of tightly coupling Ruby and R (JRuby or CRuby + GNU R, Galaaz 2.0)"
4
+ author: "Rodrigo Botafogo"
5
+ tags: [Galaaz, Ruby, R, JRuby, CRuby, "GNU R", ggplot2]
6
+ date: "16 October 2018 (narrative updated for Galaaz 2.0, 2026)"
7
+ output:
8
+ html_document:
9
+ self_contained: true
10
+ keep_md: true
11
+ toc: true
12
+ toc_float: true
13
+ toc_depth: 2
14
+ number_sections: true
15
+ includes:
16
+ before_body: _logo_before_body.html
17
+ pdf_document:
18
+ includes:
19
+ in_header:
20
+ - "../../sty/galaaz.sty"
21
+ - "../../sty/galaaz-headers-from-p3.tex"
22
+ keep_tex: yes
23
+ number_sections: yes
24
+ toc: true
25
+ toc_depth: 2
26
+ md_document:
27
+ variant: markdown_github
28
+ fontsize: 11pt
29
+ ---
30
+
31
+
32
+
33
+
34
+
1
35
  # Introduction
2
36
 
3
- Galaaz is a system for tightly coupling Ruby and R. Ruby is a powerful
4
- language, with a large community, a very large set of libraries and
5
- great for web development. However, it lacks libraries for data science,
6
- statistics, scientific plotting and machine learning. On the other hand,
7
- R is considered one of the most powerful languages for solving all of
8
- the above problems. **Python** is a strong competitor: NumPy, pandas,
9
- SciPy, and scikit-learn are widely used examples among **many
10
- thousands** of packages on PyPI for numerical and ML work.
11
-
12
- With Galaaz we do not intend to re-implement any of the scientific
13
- libraries in R; we allow for very tight coupling between the two
14
- languages to the point that the Ruby developer does not need to think
15
- about R syntax for every call. **Galaaz 2.0** does this with
16
- **[JRuby](https://www.jruby.org/)** or **CRuby** and **GNU R**: a
17
- **bridge** evaluates R from Ruby and exchanges data between processes.
18
-
19
- An **earlier** Galaaz prototype used Oracle’s **GraalVM** with
20
- **TruffleRuby** and **FastR** in one JVM. That stack is **historical**;
21
- today’s documentation and tooling assume **NewBridge on JRuby or CRuby**
37
+ Galaaz is a system for tightly coupling Ruby and R. Ruby is a powerful language, with
38
+ a large community, a very large set of libraries and great for web development. However,
39
+ it lacks libraries for data science, statistics, scientific plotting and machine learning.
40
+ On the other hand, R is considered one of the most powerful languages for solving all of the
41
+ above problems. **Python** is a strong competitor: NumPy, pandas, SciPy, and scikit-learn are
42
+ widely used examples among **many thousands** of packages on PyPI for numerical and ML work.
43
+
44
+ With Galaaz we do not intend to re-implement any of the scientific libraries in R; we allow
45
+ for very tight coupling between the two languages to the point that the Ruby developer does
46
+ not need to think about R syntax for every call. **Galaaz 2.0** does this with **[JRuby](https://www.jruby.org/)**
47
+ or **CRuby** and **GNU R**: a **bridge** evaluates R from Ruby and exchanges data between processes.
48
+
49
+ An **earlier** Galaaz prototype used Oracle’s **GraalVM** with **TruffleRuby** and **FastR** in one JVM.
50
+ That stack is **historical**; today’s documentation and tooling assume **NewBridge on JRuby or CRuby**
22
51
  (see the project manual and **`bin/galaaz-ruby`** / **`bin/gknit`**).
23
52
 
24
53
  For background on the old stack:
25
54
 
26
- - [GraalVM Home](https://www.graalvm.org/)
27
- - [TruffleRuby](https://github.com/oracle/truffleruby)
28
- - [FastR](https://github.com/oracle/fastr)
29
- - [Faster R with
30
- FastR](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb)
55
+ * [GraalVM Home](https://www.graalvm.org/)
56
+ * [TruffleRuby](https://github.com/oracle/truffleruby)
57
+ * [FastR](https://github.com/oracle/fastr)
58
+ * [Faster R with FastR](https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb)
31
59
 
32
60
  ## What does Galaaz mean
33
61
 
34
- Galaaz is the Portuguese name for “Galahad”. From Wikipedia:
62
+ Galaaz is the Portuguese name for "Galahad". From Wikipedia:
35
63
 
36
64
  Sir Galahad (sometimes referred to as Galeas or Galath),
37
65
  in Arthurian legend, is a knight of King Arthur's Round Table and one
@@ -48,31 +76,29 @@ Galaaz is the Portuguese name for “Galahad”. From Wikipedia:
48
76
 
49
77
  ## Prerequisites (Galaaz 2.0)
50
78
 
51
- - **JRuby** and a compatible **JDK**, *or* **CRuby 3.3+**
52
- - **GNU R** on your `PATH`
79
+ * **JRuby** and a compatible **JDK**, *or* **CRuby 3.3+**
80
+ * **GNU R** on your `PATH`
53
81
 
54
- The following R packages will be automatically installed when necessary,
55
- but could be installed prior to the demo if desired:
82
+ The following R packages will be automatically installed when necessary, but could be installed prior
83
+ to the demo if desired:
56
84
 
57
- - ggplot2
58
- - gridExtra
85
+ * ggplot2
86
+ * gridExtra
59
87
 
60
- Installation of R packages requires a development environment. On Linux,
61
- a typical build toolchain (GCC, headers) is usually enough. On macOS,
62
- Apple’s **Xcode Command Line Tools** are commonly required.
88
+ Installation of R packages requires a development environment. On Linux, a typical build toolchain
89
+ (GCC, headers) is usually enough. On macOS, Apple’s **Xcode Command Line Tools** are commonly required.
63
90
 
64
- In order to run the ‘specs’ the following Ruby package is necessary:
91
+ In order to run the 'specs' the following Ruby package is necessary:
65
92
 
66
- - gem install rspec
93
+ * gem install rspec
67
94
 
68
95
  ## Preparation
69
96
 
70
- - gem install galaaz
97
+ * gem install galaaz
71
98
 
72
99
  ## Running the demo
73
100
 
74
- The ggplot examples for this demo were adapted from:
75
- <http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html>.
101
+ The ggplot examples for this demo were adapted from: http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html.
76
102
 
77
103
  At the shell, from a suitable Galaaz environment:
78
104
 
@@ -84,20 +110,19 @@ Running
84
110
 
85
111
  galaaz -T
86
112
 
87
- lists available demo tasks. To run a demo, use **`galaaz`** where you
88
- would otherwise invoke **`rake`**. For example, if the list shows
89
- `rake sthda:bar`, run `galaaz sthda:bar`. To run every demo in the
90
- **sthda** category, use `galaaz sthda:all`. Some examples require
91
- **rspec**; install it with `gem install rspec`.
113
+ lists available demo tasks. To run a demo, use **`galaaz`** where you would otherwise invoke **`rake`**.
114
+ For example, if the list shows `rake sthda:bar`, run `galaaz sthda:bar`. To run every demo in the **sthda**
115
+ category, use `galaaz sthda:all`. Some examples require **rspec**; install it with `gem install rspec`.
92
116
 
93
117
  # The demo code
94
118
 
95
- The following is the Ruby code and plot for the above example. There is
96
- a small difference between the code in the example and the code below.
97
- If the example is **run**, the plot will appear on the screen; below, we
98
- generate an SVG image and then include it in this document. In order to
99
- generate and image, the R.svg device is used. To generate the plot on
100
- the screen, use the R.awt device, as commented on the code.
119
+
120
+ The following is the Ruby code and plot for the above example. There is a small difference between
121
+ the code in the example and the code below. If the example is **run**, the plot will appear on the
122
+ screen; below, we generate an SVG image and then include it in this document. In order to
123
+ generate and image, the R.svg device is used. To generate the plot on the screen, use the R.awt
124
+ device, as commented on the code.
125
+
101
126
 
102
127
  ``` ruby
103
128
  require 'galaaz'
@@ -124,10 +149,13 @@ gg = midwest.ggplot(E.aes(x: :area, y: :poptotal)) +
124
149
  puts gg
125
150
  ```
126
151
 
127
- ![](galaaz_ggplot_files/figure-markdown_github/midwest_rb.png)
152
+
153
+ ![](galaaz_ggplot_files/figure-html/midwest_rb.png)
154
+
128
155
 
129
156
  In R, the code to generate this plot is the following
130
157
 
158
+
131
159
  ``` r
132
160
  # install.packages("ggplot2")
133
161
  # load package and data
@@ -152,42 +180,37 @@ gg <- ggplot(midwest, aes(x=area, y=poptotal)) +
152
180
  plot(gg)
153
181
  ```
154
182
 
155
- Note that both codes are very similar. The Ruby code requires the use of
156
- “R.” before calling any functions, for instance R function ‘geom_point’
157
- becomes ‘R.geom_point’ in Ruby. R named parameters such as (col = state,
158
- size = popdensity), become in Ruby (col: :state, size: :popdensity).
159
-
160
- One last point that needs to be observed is the call to the ‘aes’
161
- function. In Ruby instead of doing ‘R.aes’, we use ‘E.aes’. The
162
- explanation of why E.aes is needed is an advanced topic in R and depends
163
- on what is know as Non-standard Evaluation (NSE) in R. In short,
164
- function ‘aes’ is lazily evaluated in R, i.e., in R when calling
165
- geom_point(aes(col=state, size=popdensity)), function geom_point
166
- receives as argument something similar to a string containing
167
- ‘aes(col=state, size=popdensity)’, and the aes function will be
168
- evaluated inside the geom_point function. In Ruby, there is no Lazy
169
- evaluation and doing R.aes would try to evaluate aes immediately. In
170
- order to delay the evaluation of function aes we need to use E.aes. The
171
- interested reader on NSE in R is directed to
172
- <http://adv-r.had.co.nz/Computing-on-the-language.html>.
183
+ Note that both codes are very similar. The Ruby code requires the use of "R." before calling
184
+ any functions,
185
+ for instance R function 'geom_point' becomes 'R.geom_point' in Ruby. R named parameters such as
186
+ (col = state, size = popdensity), become in Ruby (col: :state, size: :popdensity).
187
+
188
+ One last
189
+ point that needs to be observed is the call to the 'aes' function. In Ruby instead of doing
190
+ 'R.aes', we use 'E.aes'. The explanation of why E.aes is needed is an advanced topic in R and
191
+ depends on what is know as Non-standard Evaluation (NSE) in R. In short, function 'aes' is lazily
192
+ evaluated in R, i.e., in R when calling geom_point(aes(col=state, size=popdensity)), function
193
+ geom_point receives as argument something similar to a string containing
194
+ 'aes(col=state, size=popdensity)', and the aes function will be evaluated inside the geom_point
195
+ function. In Ruby, there is no Lazy evaluation and doing R.aes would try to evaluate aes
196
+ immediately. In order to delay the evaluation of function aes we need to use E.aes. The
197
+ interested reader on NSE in R is directed to http://adv-r.had.co.nz/Computing-on-the-language.html.
173
198
 
174
199
  # An extension to the example
175
200
 
176
- If both codes are so similar, then why would one use Ruby instead of R
177
- and what good is galaaz after all?
201
+ If both codes are so similar, then why would one use Ruby instead of R and what good is galaaz
202
+ after all?
203
+
204
+ Ruby is a modern OO language with numerous very useful constructs such as classes, modules, blocks,
205
+ procs, etc. The example above focus on the coupling of both languages, and does not show the
206
+ use of other Ruby constructs. In the following example, we will show a more complex example using
207
+ other Ruby constructs. This is certainly not a very well written and robust Ruby code, but
208
+ it give the idea of how Ruby and R are strongly coupled.
178
209
 
179
- Ruby is a modern OO language with numerous very useful constructs such
180
- as classes, modules, blocks, procs, etc. The example above focus on the
181
- coupling of both languages, and does not show the use of other Ruby
182
- constructs. In the following example, we will show a more complex
183
- example using other Ruby constructs. This is certainly not a very well
184
- written and robust Ruby code, but it give the idea of how Ruby and R are
185
- strongly coupled.
210
+ Let's imagine that we work in a corporation that has its plot themes. So, it has defined a
211
+ 'CorpTheme' module. Plots in this corporation should not have grids, numbers in labels should
212
+ not use scientific notation and the preferred color is blue.
186
213
 
187
- Let’s imagine that we work in a corporation that has its plot themes.
188
- So, it has defined a ‘CorpTheme’ module. Plots in this corporation
189
- should not have grids, numbers in labels should not use scientific
190
- notation and the preferred color is blue.
191
214
 
192
215
  ``` ruby
193
216
  # corp_theme.rb
@@ -234,6 +257,7 @@ end
234
257
 
235
258
  We now define a ScatterPlot class:
236
259
 
260
+
237
261
  ``` ruby
238
262
  # ScatterPlot.rb
239
263
  # creates a scatter plot and allow some configuration
@@ -325,8 +349,8 @@ class ScatterPlot
325
349
  end
326
350
  ```
327
351
 
328
- And this is the final code for making the scatter plot with the midwest
329
- data
352
+ And this is the final code for making the scatter plot with the midwest data
353
+
330
354
 
331
355
  ``` ruby
332
356
  require 'galaaz'
@@ -345,27 +369,23 @@ sp.add_smoothing_line(method: "glm")
345
369
  sp.plot
346
370
  ```
347
371
 
348
- ![](galaaz_ggplot_files/figure-markdown_github/scatter_plot_rb.png)
372
+
373
+ ![](galaaz_ggplot_files/figure-html/scatter_plot_rb.png)
349
374
 
350
375
  # Conclusion
351
376
 
352
- R is a very powerful language for statistical analysis, data analytics,
353
- machine learning, plotting and many other scientific applications with a
354
- very large package ecosystem. However R is often considered hard to
355
- learn and lacking modern language features such as object-oriented
356
- classes, modules, and first-class functions. For that reason, many teams
357
- have standardized on Python (or stayed entirely inside R) rather than
358
- mixing ecosystems.
359
-
360
- With Galaaz, R programmers can almost transparently migrate from R to
361
- Ruby, since syntax is almost identical and **GNU R** remains the engine
362
- for statistics and **ggplot2**. Further, by using Galaaz the R developer
363
- can start (slowly if needed) using Ruby’s constructs and libraries that
377
+ R is a very powerful language for statistical analysis, data analytics, machine learning, plotting
378
+ and many other scientific applications with a very large package ecosystem. However R is often
379
+ considered hard to learn and lacking modern language features such as object-oriented
380
+ classes, modules, and first-class functions. For that reason, many teams have standardized on
381
+ Python (or stayed entirely inside R) rather than mixing ecosystems.
382
+
383
+ With Galaaz, R programmers can almost transparently migrate from R to Ruby, since syntax is
384
+ almost identical and **GNU R** remains the engine for statistics and **ggplot2**. Further, by using
385
+ Galaaz the R developer can start (slowly if needed) using Ruby’s constructs and libraries that
364
386
  nicely complement R packages.
365
387
 
366
- For the Ruby developer, Galaaz allows the immediate use of R functions
367
- with minimal ceremony. As shown in the second example above, class
368
- `ScatterPlot` hides most R call details from the Ruby developer. Prefer
369
- **JRuby** when you want **real parallel threads** on the Ruby side and
370
- access to the JVM ecosystem; **CRuby** works equally for the Galaaz
371
- bridge itself.
388
+ For the Ruby developer, Galaaz allows the immediate use of R functions with minimal ceremony. As
389
+ shown in the second example above, class `ScatterPlot` hides most R call details from the Ruby
390
+ developer. Prefer **JRuby** when you want **real parallel threads** on the Ruby side and access to
391
+ the JVM ecosystem; **CRuby** works equally for the Galaaz bridge itself.
@@ -101,7 +101,7 @@
101
101
  \usepackage[utf8]{inputenc}
102
102
 
103
103
  \usepackage{geometry}
104
- \geometry{a4paper, top=1in}
104
+ \geometry{a4paper, top=1.05in, headheight=30pt, headsep=14pt}
105
105
 
106
106
  % needed for kableExtra
107
107
  \usepackage{longtable}
@@ -122,29 +122,60 @@
122
122
  \usepackage{graphicx}
123
123
 
124
124
  \usepackage{fancyhdr}
125
- % set the header and foot style
126
- % style 'fancy' adds the section name on the header
127
- % and the page number on the footer
125
+ % Header: small Galaaz mark (left); page number + section title (right),
126
+ % matching classic LaTeX style: "4 AN EXTENSION TO THE EXAMPLE"
127
+ % (upright page number, uppercase italic section name).
128
+ % Logo paths cover repo blogs (../../sty/), installed ~/sty/, and local images/.
129
+ % Blogs may delay headers with \renewcommand{\galaazheaderfrompage}{3} after this sty
130
+ % (e.g. skip title/TOC and a logo splash page).
131
+ \newcommand{\galaazheaderfrompage}{1}
132
+ \newcommand{\galaazheaderlogo}{%
133
+ \raisebox{-0.12\height}{%
134
+ \IfFileExists{../../sty/galaaz-header.png}{%
135
+ \includegraphics[height=0.32in]{../../sty/galaaz-header.png}%
136
+ }{%
137
+ \IfFileExists{galaaz-header.png}{%
138
+ \includegraphics[height=0.32in]{galaaz-header.png}%
139
+ }{%
140
+ \IfFileExists{images/galaaz-header.png}{%
141
+ \includegraphics[height=0.32in]{images/galaaz-header.png}%
142
+ }{}%
143
+ }%
144
+ }%
145
+ }%
146
+ }
147
+ % Section title only in marks (no \thesection); page number is separate.
148
+ \renewcommand{\sectionmark}[1]{\markboth{#1}{}}
149
+ \renewcommand{\subsectionmark}[1]{}% keep the current section in the header
150
+ \newcommand{\galaazmaybeheaderlogo}{%
151
+ \ifnum\value{page}<\galaazheaderfrompage\relax\else\galaazheaderlogo\fi}
152
+ \newcommand{\galaazmayberighthead}{%
153
+ \ifnum\value{page}<\galaazheaderfrompage\relax
154
+ \else
155
+ \textup{\thepage}\hspace{1em}\textit{\MakeUppercase{\leftmark}}%
156
+ \fi
157
+ }
128
158
  \pagestyle{fancy}
129
-
130
- % style 'fancyhf' leaves header and footer empty
131
- %\fancyhf{}
132
-
133
- % sets the left head element to \rightmark, which contains the
134
- % current section (\leftmark is the current chapter)
135
- %\fancyhead[L]{\rightmark} .
136
-
137
- % sets the right head element to the page number.
138
- % \fancyhead[R]{\thepage}
139
-
140
- % lets the head rule disappear.
141
- % \renewcommand{\headrulewidth}{0pt}
142
- % Possible selectors for the optional argument of \fancyhead/\fancyfoot
143
- % are L (left), C (center) or R (right) for the position of the element
144
- % and E (even) or O (odd) to distinguish even and odd pages. If you omit
145
- % E/O the element is set for all pages.
146
-
147
- % \usepackage{lipsum}
159
+ \fancyhf{}
160
+ \fancyhead[L]{\galaazmaybeheaderlogo}
161
+ \fancyhead[R]{\galaazmayberighthead}
162
+ \renewcommand{\headrulewidth}{0.3pt}
163
+ \makeatletter
164
+ \renewcommand{\headrule}{%
165
+ \ifnum\value{page}<\galaazheaderfrompage\relax
166
+ \else
167
+ \hrule\@height\headrulewidth\@width\headwidth
168
+ \vskip-\headrulewidth
169
+ \fi
170
+ }
171
+ \makeatother
172
+ % First page often uses plain; same conditional header logic.
173
+ \fancypagestyle{plain}{%
174
+ \fancyhf{}%
175
+ \fancyhead[L]{\galaazmaybeheaderlogo}%
176
+ \fancyhead[R]{\galaazmayberighthead}%
177
+ \renewcommand{\headrulewidth}{0.3pt}%
178
+ }
148
179
 
149
180
  % make available command lastpage
150
181
  \usepackage{lastpage}
@@ -189,6 +220,10 @@
189
220
 
190
221
  %
191
222
  %\newcommand{\atraso}[1]{\color{red} \textbf {Tempo desde a Assinatura do Contrato: #1 dias}}
223
+ % No header on title/TOC (p.1) or splash logo page (p.2);
224
+ % logo + page number + section title from page 3 onward.
225
+ % Load after galaaz.sty.
226
+ \renewcommand{\galaazheaderfrompage}{3}
192
227
  \usepackage{bookmark}
193
228
  \IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
194
229
  \urlstyle{same}
@@ -217,6 +252,8 @@ GNU R, Galaaz 2.0)}
217
252
  \setcounter{tocdepth}{2}
218
253
  \tableofcontents
219
254
  }
255
+ \begin{center}\includegraphics[width=0.45\linewidth]{images/galaaz-lockup-stacked} \end{center}
256
+
220
257
  \section{Introduction}\label{introduction}
221
258
 
222
259
  Galaaz is a system for tightly coupling Ruby and R. Ruby is a powerful
@@ -9,12 +9,22 @@ bibliography: stats.bib
9
9
  output:
10
10
  pdf_document:
11
11
  includes:
12
- in_header: ["../../sty/galaaz.sty"]
12
+ in_header:
13
+ - "../../sty/galaaz.sty"
14
+ - "../../sty/galaaz-headers-from-p3.tex"
13
15
  keep_tex: yes
14
16
  number_sections: yes
17
+ toc: true
18
+ toc_depth: 2
15
19
  html_document:
16
20
  self_contained: true
17
21
  keep_md: true
22
+ toc: true
23
+ toc_float: true
24
+ toc_depth: 2
25
+ number_sections: true
26
+ includes:
27
+ before_body: _logo_before_body.html
18
28
  biblio-style: apsr
19
29
  ---
20
30
 
@@ -22,6 +32,11 @@ biblio-style: apsr
22
32
  options(width = 70)
23
33
  ```
24
34
 
35
+ ```{r brand_logo, echo=FALSE, fig.align='center', out.width='45%', eval=knitr::is_latex_output()}
36
+ # PDF only — HTML uses _logo_before_body.html (above the TOC).
37
+ knitr::include_graphics("images/galaaz-lockup-stacked.png")
38
+ ```
39
+
25
40
  # Introduction
26
41
 
27
42
  The idea of "literate programming" was first introduced by Donald Knuth in the
data/blogs/gknit/gknit.md CHANGED
@@ -9,17 +9,29 @@ bibliography: stats.bib
9
9
  output:
10
10
  pdf_document:
11
11
  includes:
12
- in_header: ["../../sty/galaaz.sty"]
12
+ in_header:
13
+ - "../../sty/galaaz.sty"
14
+ - "../../sty/galaaz-headers-from-p3.tex"
13
15
  keep_tex: yes
14
16
  number_sections: yes
17
+ toc: true
18
+ toc_depth: 2
15
19
  html_document:
16
20
  self_contained: true
17
21
  keep_md: true
22
+ toc: true
23
+ toc_float: true
24
+ toc_depth: 2
25
+ number_sections: true
26
+ includes:
27
+ before_body: _logo_before_body.html
18
28
  biblio-style: apsr
19
29
  ---
20
30
 
21
31
 
22
32
 
33
+
34
+
23
35
  # Introduction
24
36
 
25
37
  The idea of "literate programming" was first introduced by Donald Knuth in the
@@ -133,7 +133,7 @@
133
133
  \usepackage[utf8]{inputenc}
134
134
 
135
135
  \usepackage{geometry}
136
- \geometry{a4paper, top=1in}
136
+ \geometry{a4paper, top=1.05in, headheight=30pt, headsep=14pt}
137
137
 
138
138
  % needed for kableExtra
139
139
  \usepackage{longtable}
@@ -154,29 +154,60 @@
154
154
  \usepackage{graphicx}
155
155
 
156
156
  \usepackage{fancyhdr}
157
- % set the header and foot style
158
- % style 'fancy' adds the section name on the header
159
- % and the page number on the footer
157
+ % Header: small Galaaz mark (left); page number + section title (right),
158
+ % matching classic LaTeX style: "4 AN EXTENSION TO THE EXAMPLE"
159
+ % (upright page number, uppercase italic section name).
160
+ % Logo paths cover repo blogs (../../sty/), installed ~/sty/, and local images/.
161
+ % Blogs may delay headers with \renewcommand{\galaazheaderfrompage}{3} after this sty
162
+ % (e.g. skip title/TOC and a logo splash page).
163
+ \newcommand{\galaazheaderfrompage}{1}
164
+ \newcommand{\galaazheaderlogo}{%
165
+ \raisebox{-0.12\height}{%
166
+ \IfFileExists{../../sty/galaaz-header.png}{%
167
+ \includegraphics[height=0.32in]{../../sty/galaaz-header.png}%
168
+ }{%
169
+ \IfFileExists{galaaz-header.png}{%
170
+ \includegraphics[height=0.32in]{galaaz-header.png}%
171
+ }{%
172
+ \IfFileExists{images/galaaz-header.png}{%
173
+ \includegraphics[height=0.32in]{images/galaaz-header.png}%
174
+ }{}%
175
+ }%
176
+ }%
177
+ }%
178
+ }
179
+ % Section title only in marks (no \thesection); page number is separate.
180
+ \renewcommand{\sectionmark}[1]{\markboth{#1}{}}
181
+ \renewcommand{\subsectionmark}[1]{}% keep the current section in the header
182
+ \newcommand{\galaazmaybeheaderlogo}{%
183
+ \ifnum\value{page}<\galaazheaderfrompage\relax\else\galaazheaderlogo\fi}
184
+ \newcommand{\galaazmayberighthead}{%
185
+ \ifnum\value{page}<\galaazheaderfrompage\relax
186
+ \else
187
+ \textup{\thepage}\hspace{1em}\textit{\MakeUppercase{\leftmark}}%
188
+ \fi
189
+ }
160
190
  \pagestyle{fancy}
161
-
162
- % style 'fancyhf' leaves header and footer empty
163
- %\fancyhf{}
164
-
165
- % sets the left head element to \rightmark, which contains the
166
- % current section (\leftmark is the current chapter)
167
- %\fancyhead[L]{\rightmark} .
168
-
169
- % sets the right head element to the page number.
170
- % \fancyhead[R]{\thepage}
171
-
172
- % lets the head rule disappear.
173
- % \renewcommand{\headrulewidth}{0pt}
174
- % Possible selectors for the optional argument of \fancyhead/\fancyfoot
175
- % are L (left), C (center) or R (right) for the position of the element
176
- % and E (even) or O (odd) to distinguish even and odd pages. If you omit
177
- % E/O the element is set for all pages.
178
-
179
- % \usepackage{lipsum}
191
+ \fancyhf{}
192
+ \fancyhead[L]{\galaazmaybeheaderlogo}
193
+ \fancyhead[R]{\galaazmayberighthead}
194
+ \renewcommand{\headrulewidth}{0.3pt}
195
+ \makeatletter
196
+ \renewcommand{\headrule}{%
197
+ \ifnum\value{page}<\galaazheaderfrompage\relax
198
+ \else
199
+ \hrule\@height\headrulewidth\@width\headwidth
200
+ \vskip-\headrulewidth
201
+ \fi
202
+ }
203
+ \makeatother
204
+ % First page often uses plain; same conditional header logic.
205
+ \fancypagestyle{plain}{%
206
+ \fancyhf{}%
207
+ \fancyhead[L]{\galaazmaybeheaderlogo}%
208
+ \fancyhead[R]{\galaazmayberighthead}%
209
+ \renewcommand{\headrulewidth}{0.3pt}%
210
+ }
180
211
 
181
212
  % make available command lastpage
182
213
  \usepackage{lastpage}
@@ -221,6 +252,10 @@
221
252
 
222
253
  %
223
254
  %\newcommand{\atraso}[1]{\color{red} \textbf {Tempo desde a Assinatura do Contrato: #1 dias}}
255
+ % No header on title/TOC (p.1) or splash logo page (p.2);
256
+ % logo + page number + section title from page 3 onward.
257
+ % Load after galaaz.sty.
258
+ \renewcommand{\galaazheaderfrompage}{3}
224
259
  \usepackage{booktabs}
225
260
  \usepackage{longtable}
226
261
  \usepackage{array}
@@ -251,6 +286,12 @@
251
286
  \begin{document}
252
287
  \maketitle
253
288
 
289
+ {
290
+ \setcounter{tocdepth}{2}
291
+ \tableofcontents
292
+ }
293
+ \begin{center}\includegraphics[width=0.45\linewidth]{images/galaaz-lockup-stacked} \end{center}
294
+
254
295
  \section{Introduction}\label{introduction}
255
296
 
256
297
  The idea of ``literate programming'' was first introduced by Donald