yatex

view yatexadd.el @ 8:c746646cecf5

Restrict YaTeX:framebox in picture environment.
author yuuji
date Tue, 04 May 1993 13:00:17 +0000
parents 49be9ccb0b65
children 390df0e505da
line source
1 ;;; -*- Emacs-Lisp -*-
2 ;;; YaTeX add-in functions.
3 ;;; yatexadd.el rev.3
4 ;;; (c)1991-1993 by HIROSE Yuuji.[yuuji@ae.keio.ac.jp]
5 ;;; Last modified Tue May 4 21:50:37 1993 on figaro
6 ;;; $Id$
8 (provide 'yatexadd)
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 ()
18 "YaTeX add-in function for tabular environment."
19 (let (bars (rule "") (j 0) (loc (YaTeX:read-position "tb")))
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))
26 (message "")
27 (format "%s{%s}" loc rule))
28 )
30 (defun YaTeX:read-position (oneof)
31 (let ((pos "") loc)
32 (while (not (string-match
33 (setq loc (read-key-sequence
34 (format "Position (`%s') [%s]: " oneof pos)))
35 "\r\^g\n"))
36 (cond
37 ((string-match loc oneof)
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)
44 (message "Please input one of `%s'." oneof)
45 (sit-for 3))))
46 (message "")
47 (if (string= pos "") ""
48 (concat "[" pos "]")))
49 )
51 (defun YaTeX:table ()
52 "YaTeX add-in function for table environment."
53 (YaTeX:read-position "htbp")
54 )
56 (defun YaTeX:description ()
57 "Truly poor service:-)"
58 (setq single-command "item[]")
59 ""
60 )
62 (defun YaTeX:itemize ()
63 "It's also poor service."
64 (setq single-command "item")
65 ""
66 )
68 (fset 'YaTeX:enumerate 'YaTeX:itemize)
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 )
79 (defun YaTeX:put ()
80 (YaTeX:read-coordinates "Pos")
81 )
83 (defun YaTeX:makebox ()
84 (concat (YaTeX:read-coordinates "Dimension")
85 (YaTeX:read-position "lrtb"))
86 )
88 (defun YaTeX:framebox ()
89 (if (YaTeX-quick-in-environment-p "picture")
90 (YaTeX:makebox))
91 )
93 (defun YaTeX:dashbox ()
94 (concat "{" (read-string "Dash dimension: ") "}"
95 (YaTeX:read-coordinates "Dimension"))
96 )
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 )
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 )
116 (fset 'YaTeX:int 'YaTeX:sum)
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 )
128 (defun YaTeX:gcd ()
129 "Add-in function for \\gcd(m,n)."
130 (YaTeX:check-completion-type 'maketitle)
131 (YaTeX:read-coordinates "\\gcd" "(?,)" "(,?)")
132 )
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 )
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 )