Commit 29ba9721 authored by Liam Healy's avatar Liam Healy

Improve LaTeX output of jd-table

parent 7b201a30
;; Datime formats, compatibility with non-iso8601.
;; 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
;;
;; This program is free software: you can redistribute it and/or modify
......@@ -99,11 +99,11 @@
"July" "August" "September" "October" "November" "December"))
(defun jd-table (start-year end-year &optional (format :org))
"Write out a JD table in TeX, e.g. for class.
If d is the day of the month, add d+0.5 to the table
to get the J2000 day number for that day.
If csv is T, use csv for import into spread sheet.
IF nil, use TeX."
"Write out a J2000 day number table. Output format is org-mode table (:org), LaTeX (:tex), or comma-separated values (:csv)."
(when (eq format :tex)
(format t
"\\begin{tabular}{c|~a}~&"
(make-sequence 'string (1+ (- end-year start-year)) :initial-element #\c)))
(format t (case format (:org "| Month\\Year") (t " Month")))
(loop for year from start-year to end-year
do
......@@ -113,14 +113,16 @@
(:org "| ~d")
(:tex "& ~d"))
year))
(when (eq format :org) (format t "|~&|-"))
(case format
(:org (format t "|~&|-"))
(:tex (format t "\\\\ \\hline")))
(loop for month from 1 to 12
do
(format t
(ecase format
(:csv "~& ~a")
(:org "~&| ~a")
(:tex "\\\\ ~& ~a "))
(:tex (if (eq month 1) "~& ~a " "\\\\ ~& ~a ")))
(elt (if (eq format :org) *month-names-full* *month-names*) (1- month)))
(loop for year from start-year to end-year
do
......@@ -135,4 +137,5 @@
(make-timeparse-majord year month 1)
:scale :utc))
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