Created
December 26, 2013 17:55
-
-
Save guicho271828/8136699 to your computer and use it in GitHub Desktop.
年賀状の宛名をtex + lispで作る ref: http://qiita.com/guicho271828/items/650143cf4ea6e1ff7676
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
(ql:quickload :alexandria) | |
(ql:quickload :inferior-shell) | |
(ql:quickload :cl-csv) | |
(ql:quickload :osicat) | |
(in-package :cl-user) | |
(use-package :alexandria) | |
(use-package :inferior-shell) | |
(use-package :cl-csv) | |
(use-package :osicat) ;; 2 conflict | |
;; http://www.ymeme.com/slurping-a-file-common-lisp-83.html | |
(defun slurp (stream) | |
(let ((seq (make-array (file-length stream) | |
:element-type 'character | |
:fill-pointer t))) | |
(setf (fill-pointer seq) (read-sequence seq stream)) | |
seq)) | |
(defun read-file-to-string (path) | |
(with-input-from-file (s path) | |
(slurp s))) | |
;; http://homepage2.nifty.com/domae/tex/atena.html | |
;; 古いので sjis + DOS改行コード | |
;; | |
;; atena.sty --> dos2unix , nkf --in-place -J -w8 | |
;; | |
(defun take-tex () | |
(read-file-to-string "atena/2014.tex")) | |
(defun format-tex (data s) | |
(format s (take-tex) data)) | |
(format-tex '(("なかじま" "123-0348" "千葉東京ディズニーランド") | |
("なかじま2" "124-0348" "北海道札幌1-1-1-1-1-1-1")) | |
t) | |
(defun %make-pdf (data) | |
(with-open-file (s "atena/temp.tex" | |
:direction :output | |
:if-does-not-exist :create | |
:if-exists :supersede) | |
(format-tex data s)) | |
(run/s `(progn (cd "atena") | |
(platex "temp.tex") | |
(dvipdfm "temp.dvi") | |
(mv "temp.pdf" "../2014-atena.pdf")) | |
:show t)) | |
(%make-pdf '(("なかじま" "123-0348" "千葉東京ディズニーランド") | |
("なかじま2" "124-0348" "北海道札幌1-1-1-1-1-1-1"))) | |
(defun make-pdf (csv-path) | |
(%make-pdf (csv-data csv-path))) | |
(defun csv-data (path) | |
(with-input-from-file (s path) | |
(read-csv s))) | |
(csv-data "addresses.csv") | |
;; なかやまきんに君,000-0000,札幌1-1-1-1-1-1 | |
(make-pdf "addresses.csv") |
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
\documentclass{jarticle} | |
\usepackage[hagaki,nenga]{atena} | |
\usepackage{graphicx} | |
\begin{document} | |
%=======差出人設定================ | |
\sasidasinin{浅井 政太郎}{000-0000}{東京都目黒区駒場3-8-1 東京大学駒場キャンパス} | |
%=======表書き開始============== | |
\begin{atena} | |
~:{ | |
\personal{~a}{~a}{~a} | |
~} | |
\end{atena} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment