Wed Jun 5 11:34:38 JST 2013

scheme into tex

gosh report.scm > report.tex

文字列をいちいちダブルクオーテーションで括らないといけないのは 実用性に疑問

latexを8分割で印刷させたい beamerで書いた場合に非常に有用

split8 :
    platex $(FILE).tex
    dvips $(FILE).dvi > $(FILE).ps
    pstops -pa4 '8:0@.7(1cm,22.2cm)+1@.7(11.2cm,22.2cm)+2@.7(1cm,14.9cm)+3@.7(11.2cm,14.9cm)+4@.7(1cm,7.7cm)+5@.7(11.2cm,7.7cm)+6@.7(1cm,0.4cm)+7@.7(11.2cm,0.4cm)' $(FILE).ps | sed 's/363 273/596 842/g' > $(FILE)-8.ps

意味は全くわかってない 普通にlatex環境があれば platex, dvips はあるけど pstops だけ今入れる必要が あった

以下,現時点の tex.scm

(define-syntax tex
 (syntax-rules ()
  ((tex x ...)
   (map display (list x ...)))))
;;;;

(define (x-append . args) (apply string-append (map x->string args)))
(define (x-join ls del) (string-join (map x->string ls) del))

; keyword name => \name
(define (keyword name)
    (x-append "\\" name " "))
(define yen keyword)

; keyword/option name option => \name[option]
(define (keyword/option name option)
    (x-append "\\" name "[" option "]"))

; tag name hoge hige => \name{hoge hige}
(define (tag name . args)
    (let1 contents (x-join args " ")
    (x-append "\\" name "{" contents "}")))

(define (tag2 name arg1 arg2)
    (x-append "\\" name "{" arg1 "}{" arg2 "}"))

; \name[option]{hoge hare}
(define (tag/option name option . args)
    (let1 contents (x-join args " ")
    (x-append "\\" name "[" option "]" "{" contents "}")))

; env name hoge hige => \begin{name} hoge hige \end{name}
(define (env name . args)
    (let1 contents (x-join args "\n")
    (x-append "\\begin{" name "}\n" contents "\n\\end{" name "}\n")))

(define (env2 name option . args)
  (let1 contents (x-join args "\n")
  (x-append "\\begin{" name "}{" option "}\n" contents "\n\\end{" name "}\n")))

;;;; tag
(define (jsarticle . args)
    (if (zero? (length args))
        (tag 'documentclass 'jsarticle)
        (let1 options (x-join args ",")
            (tag/option 'documentclass options 'jsarticle))))

(define (beamer . args)
  (x-append
    (if (zero? (length args))
        (tag 'documentclass 'beamer)
        (let1 options (x-join args ",")
            (tag/option 'documentclass options 'beamer)))
    "\\setbeamertemplate{navigation symbols}{} "))

(define (usetheme . args)     (tag 'usetheme (x-join args ",")))
(define (usefonttheme . args) (tag 'usefonttheme (x-join args ",")))
(define (usepackage . args)   (tag 'usepackage (x-join args ",")))

(define (title . args) (apply tag 'title args))
(define (author . args) (apply tag 'author args))
(define (frametitle . args) (apply tag 'frametitle args))
(define (date . args) (apply tag 'date args))
(define (thanks . args) (apply tag 'thanks args))
(define thanx thanks)

(define (sqrt x) (tag 'sqrt x))
(define (hat x)  (tag 'hat x))
(define (lnot x)  (tag 'lnot x))
(define (--> x)  (tag 'xrightarrow x))
(define (bra . args) (tag 'bra (x-join args ", ")))
(define (ket . args) (tag 'ket (x-join args ", ")))
(define (braket x y) (tag 'braket (x-append x "|" y)))

(define (over x y) (tag2 'overset x y))
(define (frac a b) (tag2 'frac a b)) (define / frac)

(define sum
  (let1 pre "\\displaystyle \\sum"
  (case-lambda
    (() (x-append pre))
    ((sub) (x-append pre "_{"sub"}"))
    ((sub sup) (x-append pre "_{"sub"}" "^{"sup"}")))))

(define (text . args)
  (let1 contents (x-join args " ")
  (tag 'text contents)))

;;; env

(define (document . args)  (apply env 'document args))
(define (enumerate . args) (apply env 'enumerate args))
(define (eqnarray . args)  (apply env 'eqnarray args))
(define (eqnarray* . args) (apply env 'eqnarray* args))
(define (equation . args)  (apply env 'equation args))
(define (theorem . args) (apply env 'theorem args))
(define (proof . args)   (apply env 'proof args))

(define (frame . args)
  (cond ((equal? (car args) #t)
           (apply env2 'frame (cadr args) (cddr args)))
        (else
          (apply env 'frame args))))

;;; keywords

(define titlepage "\\frame{\\titlepage}")
(define maketitle (keyword 'maketitle))
(define newline (keyword 'newline))
(define emptyline "\\;\n\n")
(define today  (keyword 'today))

(define |\\| "\\\\")
(define & "&")

(define in     (keyword 'in))
(define subset (keyword 'subset))
(define forall (keyword 'forall))
(define exists (keyword 'exists))
(define dots (keyword 'dots))
(define pm   (keyword 'pm))
(define dagger (keyword 'dagger))

(define ne   (keyword 'ne)) (define != ne)
(define le   (keyword 'le))
(define ge   (keyword 'ge))
(define ===  (keyword 'equiv))
(define ->   (keyword 'rightarrow))
(define <-   (keyword 'leftarrow))
(define =>   (keyword 'Rightarrow))
(define <=>  (keyword 'Leftrightarrow))

(define alpha (yen 'alpha))
(define beta  (yen 'beta))
(define kappa (yen 'kappa))
(define varphi (yen 'varphi))

(define (diff x y) (x-append x (keyword 'setminus) y))
(define (max . args)
  (x-append (keyword 'max) "\\{" (x-join args ",") "\\}"))

(define (item . args)
  (define (opt a)
    (cond ((string? a) `("[" ,a "]"))
          ((number? a) `("<" ,a "->"))
          (else '())))
  (apply x-append (keyword 'item) (concatenate (map opt args))))

(define (alert . args)
  (let1 contents (x-join args " ")
  (tag 'alert contents)))

;; others
(define (eqn . args)
  (let1 contents (x-join args " ")
  (x-append "\\[ " contents " \\]")))

(define ($ . args)
  (let1 contents (x-join args " ")
  (x-append " $" contents "$ ")))

(define (^ x t) (x-append x "^{" t "}"))
(define (_ x t) (x-append x "_{" t "}"))
(define (+ . args) (x-join args "+"))
(define (* . args) (x-join args " "))
(define (times . args) (x-join args (keyword 'times)))
(define (- . args)
  (if (= (length args) 1)
      (x-append "-" (car args))
      (paren (x-join args "-"))))
(define ++ "+\\hbox to 3pt{\\hss +}")

(define (paren . args)
  (let1 contents (x-join args " ")
  (x-append "(" contents ")")))

(define (comma . args) (x-join args ", "))

Wed Jun 5 15:23:24 JST 2013

プロジェクター実験

先週xfceのパソコンでプロジェクタつないでもモニタは検知できても "output on" が出来なかった.

別のパソコンで,やはりxfce ので,xrandr 使ってできた.使わなくても できたような気がすごくするけど.

# 使える(繋がってないの含めて)モニタ出力デバイス一覧
$ xrandr -q
Screen 0: minimum 320 x 200, current 1280 x 800, maximum 8192 x 8192
LVDS1 connected 1280x800+0+0 (normal left inverted right x axis y axis) 286mm x 179mm
   1280x800       60.5*+
   1024x768       60.0  
   800x600        60.3     56.2  
   640x480        59.9  
VGA1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
DP1 disconnected (normal left inverted right x axis y axis)
HDMI2 disconnected (normal left inverted right x axis y axis)
DP2 disconnected (normal left inverted right x axis y axis)
DP3 disconnected (normal left inverted right x axis y axis)
TV1 disconnected (normal left inverted right x axis y axis)

LVDS1 がおそらく組み込みの(ノートパソコンです)のモニタ VGA1 が,私がプロジェクタ出力に使ってる穴

# 私のノートパソコンの最高解像度
$ xrandr --output LVDS1 --mode 1280x800

--modeの後でタブ補完すれば,使える解像度一覧がわかる.すごい遅いけど

# これでもたぶん大丈夫
$ xrandr --output LVDS1 --auto

# プロジェクタの解像度に合わせる
$ xrandr --output LVDS1 --mode 1024x768

# プロジェクタに出力
$ xrandr --output VGA1 --mode 1024x768

# なんか一旦別の解像度にしないと映らない
$ xrandr --output VGA1 --mode 800x600

# 今度こそいける
$ xrandr --output VGA1 --mode 1024x768