Skip to content

Instantly share code, notes, and snippets.

@ggVGc
Created April 16, 2023 12:18
Show Gist options
  • Save ggVGc/3fae81c5cd4d14eee4b8924dbf3b73d5 to your computer and use it in GitHub Desktop.
Save ggVGc/3fae81c5cd4d14eee4b8924dbf3b73d5 to your computer and use it in GitHub Desktop.
table.rkt
#lang racket
(require "latex.rkt")
(provide
table
table-env
tabular)
(define (table #:config [config null] headers . body)
(table-env
(apply
(curry tabular #:config config headers)
body)))
(define (table-env . body)
(beg #:opt "!htb" "table"
(list
(command "centering")
"\n"
body)))
(define (tabular #:config [config null] headers . entries)
(when (null? config)
(set! config
(make-list (length headers) "l")))
(beg #:arg config "tabular"
(list
(command "toprule")
(intersperse "&" headers)
(command "\\")
(command "midrule")
"\n"
(map
(lambda (x)
(list
(intersperse " & " x)
(command "\\\n")))
entries)
(command "bottomrule"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment