6
|
1 ;;; -*- Emacs-Lisp -*-
|
8
|
2 ;;; YaTeX add-in functions.
|
|
3 ;;; yatexadd.el rev.3
|
6
|
4 ;;; (c)1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
|
8
|
5 ;;; Last modified Tue May 4 21:50:37 1993 on figaro
|
|
6 ;;; $Id$
|
6
|
7
|
|
8 (provide 'yatexadd)
|
|
9
|
|
10 ;;;
|
|
11 ;;Sample functions for LaTeX environment.
|
|
12 ;;;
|
|
13 (defvar YaTeX:tabular-default-rule
|
|
14 "@{\\vrule width 1pt\\ }c|c|c@{\\ \\vrule width 1pt}"
|
|
15 "*Your favorite default rule format."
|
|
16 )
|
|
17 (defun YaTeX:tabular ()
|
8
|
18 "YaTeX add-in function for tabular environment."
|
|
19 (let (bars (rule "") (j 0) (loc (YaTeX:read-position "tb")))
|
6
|
20 (setq bars (string-to-int (read-string "Number of `|': ")))
|
|
21 (if (> bars 0)
|
|
22 (while (< j bars) (setq rule (concat rule "|")) (setq j (1+ j)))
|
|
23 (setq rule YaTeX:tabular-default-rule))
|
|
24 (setq rule (read-string "rule format: " rule))
|
|
25
|
8
|
26 (message "")
|
|
27 (format "%s{%s}" loc rule))
|
6
|
28 )
|
|
29
|
8
|
30 (defun YaTeX:read-position (oneof)
|
|
31 (let ((pos "") loc)
|
6
|
32 (while (not (string-match
|
8
|
33 (setq loc (read-key-sequence
|
|
34 (format "Position (`%s') [%s]: " oneof pos)))
|
6
|
35 "\r\^g\n"))
|
|
36 (cond
|
8
|
37 ((string-match loc oneof)
|
6
|
38 (if (not (string-match loc pos))
|
|
39 (setq pos (concat pos loc))))
|
|
40 ((and (string-match loc "\C-h\C-?") (> (length pos) 0))
|
|
41 (setq pos (substring pos 0 (1- (length pos)))))
|
|
42 (t
|
|
43 (ding)
|
8
|
44 (message "Please input one of `%s'." oneof)
|
6
|
45 (sit-for 3))))
|
8
|
46 (message "")
|
|
47 (if (string= pos "") ""
|
|
48 (concat "[" pos "]")))
|
|
49 )
|
|
50
|
|
51 (defun YaTeX:table ()
|
|
52 "YaTeX add-in function for table environment."
|
|
53 (YaTeX:read-position "htbp")
|
6
|
54 )
|
|
55
|
|
56 (defun YaTeX:description ()
|
|
57 "Truly poor service:-)"
|
|
58 (setq single-command "item[]")
|
8
|
59 ""
|
6
|
60 )
|
|
61
|
|
62 (defun YaTeX:itemize ()
|
|
63 "It's also poor service."
|
|
64 (setq single-command "item")
|
8
|
65 ""
|
6
|
66 )
|
|
67
|
|
68 (fset 'YaTeX:enumerate 'YaTeX:itemize)
|
8
|
69
|
|
70 ;;;
|
|
71 ;;Sample functions for section-type command.
|
|
72 ;;;
|
|
73 (defun YaTeX:multiput ()
|
|
74 (concat (YaTeX:read-coordinates "Pos")
|
|
75 (YaTeX:read-coordinates "Step")
|
|
76 "{" (read-string "How many times: ") "}")
|
|
77 )
|
|
78
|
|
79 (defun YaTeX:put ()
|
|
80 (YaTeX:read-coordinates "Pos")
|
|
81 )
|
|
82
|
|
83 (defun YaTeX:makebox ()
|
|
84 (concat (YaTeX:read-coordinates "Dimension")
|
|
85 (YaTeX:read-position "lrtb"))
|
|
86 )
|
|
87
|
|
88 (defun YaTeX:framebox ()
|
|
89 (if (YaTeX-quick-in-environment-p "picture")
|
|
90 (YaTeX:makebox))
|
|
91 )
|
|
92
|
|
93 (defun YaTeX:dashbox ()
|
|
94 (concat "{" (read-string "Dash dimension: ") "}"
|
|
95 (YaTeX:read-coordinates "Dimension"))
|
|
96 )
|
|
97
|
|
98 (defun YaTeX:read-coordinates (&optional mes varX varY)
|
|
99 (concat
|
|
100 "("
|
|
101 (read-string (format "%s %s: " (or mes "Dimension") (or varX "X")))
|
|
102 ","
|
|
103 (read-string (format "%s %s: " (or mes "Dimension") (or varY "Y")))
|
|
104 ")")
|
|
105 )
|
|
106
|
|
107 ;;;
|
|
108 ;;Sample functions for maketitle-type command.
|
|
109 ;;;
|
|
110 (defun YaTeX:sum ()
|
|
111 "Read range of summation."
|
|
112 (YaTeX:check-completion-type 'maketitle)
|
|
113 (concat (YaTeX:read-boundary "_") (YaTeX:read-boundary "^"))
|
|
114 )
|
|
115
|
|
116 (fset 'YaTeX:int 'YaTeX:sum)
|
|
117
|
|
118 (defun YaTeX:lim ()
|
|
119 "Insert limit notation of \\lim."
|
|
120 (YaTeX:check-completion-type 'maketitle)
|
|
121 (let ((var (read-string "Variable: ")) limit)
|
|
122 (if (string= "" var) ""
|
|
123 (setq limit (read-string "Limit ($ means infinity): "))
|
|
124 (if (string= "$" limit) (setq limit "\\infty"))
|
|
125 (concat "_{" var " \\rightarrow " limit "}")))
|
|
126 )
|
|
127
|
|
128 (defun YaTeX:gcd ()
|
|
129 "Add-in function for \\gcd(m,n)."
|
|
130 (YaTeX:check-completion-type 'maketitle)
|
|
131 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")
|
|
132 )
|
|
133
|
|
134 (defun YaTeX:read-boundary (ULchar)
|
|
135 "Read boundary usage by _ or ^. _ or ^ is indicated by argument ULchar."
|
|
136 (let ((bndry (read-string (concat ULchar "{...}: "))))
|
|
137 (if (string= bndry "") ""
|
|
138 (concat ULchar "{" bndry "}")))
|
|
139 )
|
|
140
|
|
141 (defun YaTeX:check-completion-type (type)
|
|
142 "Check valid completion type."
|
|
143 (if (not (eq type YaTeX-current-completion-type))
|
|
144 (error "This should be completed with %s-type completion." type))
|
|
145 )
|