Created
April 16, 2023 12:18
-
-
Save ggVGc/3fae81c5cd4d14eee4b8924dbf3b73d5 to your computer and use it in GitHub Desktop.
table.rkt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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