Commit 29ba9721 authored by Liam M. Healy's avatar Liam M. Healy
Browse files

Improve LaTeX output of jd-table

parent 7b201a30
;; Datime formats, compatibility with non-iso8601. ;; Datime formats, compatibility with non-iso8601.
;; Liam Healy Fri Oct 12 2001 - 16:27 ;; Liam Healy Fri Oct 12 2001 - 16:27
;; Time-stamp: <2014-01-13 21:55:47EST formats.lisp> ;; Time-stamp: <2015-09-07 10:02:16EDT formats.lisp>
;; Copyright 2011, 2013, 2014 Liam M. Healy ;; Copyright 2011, 2013, 2014, 2015 Liam M. Healy
;; Distributed under the terms of the GNU General Public License ;; Distributed under the terms of the GNU General Public License
;; ;;
;; This program is free software: you can redistribute it and/or modify ;; This program is free software: you can redistribute it and/or modify
...@@ -99,11 +99,11 @@ ...@@ -99,11 +99,11 @@
"July" "August" "September" "October" "November" "December")) "July" "August" "September" "October" "November" "December"))
(defun jd-table (start-year end-year &optional (format :org)) (defun jd-table (start-year end-year &optional (format :org))
"Write out a JD table in TeX, e.g. for class. "Write out a J2000 day number table. Output format is org-mode table (:org), LaTeX (:tex), or comma-separated values (:csv)."
If d is the day of the month, add d+0.5 to the table (when (eq format :tex)
to get the J2000 day number for that day. (format t
If csv is T, use csv for import into spread sheet. "\\begin{tabular}{c|~a}~&"
IF nil, use TeX." (make-sequence 'string (1+ (- end-year start-year)) :initial-element #\c)))
(format t (case format (:org "| Month\\Year") (t " Month"))) (format t (case format (:org "| Month\\Year") (t " Month")))
(loop for year from start-year to end-year (loop for year from start-year to end-year
do do
...@@ -113,14 +113,16 @@ ...@@ -113,14 +113,16 @@
(:org "| ~d") (:org "| ~d")
(:tex "& ~d")) (:tex "& ~d"))
year)) year))
(when (eq format :org) (format t "|~&|-")) (case format
(:org (format t "|~&|-"))
(:tex (format t "\\\\ \\hline")))
(loop for month from 1 to 12 (loop for month from 1 to 12
do do
(format t (format t
(ecase format (ecase format
(:csv "~& ~a") (:csv "~& ~a")
(:org "~&| ~a") (:org "~&| ~a")
(:tex "\\\\ ~& ~a ")) (:tex (if (eq month 1) "~& ~a " "\\\\ ~& ~a ")))
(elt (if (eq format :org) *month-names-full* *month-names*) (1- month))) (elt (if (eq format :org) *month-names-full* *month-names*) (1- month)))
(loop for year from start-year to end-year (loop for year from start-year to end-year
do do
...@@ -135,4 +137,5 @@ ...@@ -135,4 +137,5 @@
(make-timeparse-majord year month 1) (make-timeparse-majord year month 1)
:scale :utc)) :scale :utc))
3/2))) 3/2)))
(when (eq format :org) (princ "|")))) (when (eq format :org) (princ "|")))
(when (eq format :tex) (format t "~&\\end{tabular}")))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment