2 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4 ;; MODULE : elsart-num.scm
5 ;; DESCRIPTION : elsart-num style for BibTeX files
6 ;; COPYRIGHT : (C) 2010 David MICHEL
8 ;; This software falls under the GNU general public license version 3 or later.
9 ;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
10 ;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14 (texmacs-module (bibtex elsart-num)
15 (:use (bibtex bib-utils)))
17 (bib-define-style "elsart-num" "plain")
19 (tm-define (format-name x)
20 (:mode bib-elsart-num?)
21 (let* ((f (if (empty? (list-ref x 1))
23 `(concat ,(bib-abbreviate (list-ref x 1) "." `(nbsp)))))
24 (vv (if (empty? (list-ref x 2)) "" `(concat ,(list-ref x 2) (nbsp))))
25 (ll (if (empty? (list-ref x 3)) "" (list-ref x 3)))
26 (jj (if (empty? (list-ref x 4)) "" `(concat ", " ,(list-ref x 4)))))
27 `(concat ,f ,vv ,ll ,jj)))
29 (tm-define (format-editor x)
30 (:mode bib-elsart-num?)
31 (let* ((a (bib-field x "editor")))
34 (if (equal? (length a) 2)
35 `(concat ,(format-names a) ,(bib-translate " (Ed.)"))
36 `(concat ,(format-names a) ,(bib-translate " (Eds.)"))))))
38 (tm-define (format-edition x)
39 (:mode bib-elsart-num?)
40 (let* ((e (bib-field x "edition")))
41 (if (empty? e) "" `(concat ,e " Edition"))))
43 (tm-define (format-volume-or-number x)
44 (:mode bib-elsart-num?)
45 (let* ((v (bib-field x "volume"))
46 (n (bib-field x "number"))
47 (s (bib-field x "series")))
51 (let ((series (if (empty? s)
53 `(concat ,(bib-translate " in ") ,s)))
54 (sep (if (< (bib-text-length n) 3) `(nbsp) " ")))
55 `(concat "No." ,sep ,n ,series)))
56 (let ((series (if (empty? s)
58 `(concat ,(bib-translate " of ") ,s)))
59 (sep (if (< (bib-text-length v) 3) `(nbsp) " ")))
60 `(concat "Vol." ,sep ,v ,series)))))
62 (tm-define (format-pages x)
63 (:mode bib-elsart-num?)
64 (let* ((p (bib-field x "pages")))
66 ((equal? 1 (length p)) "")
67 ((equal? 2 (length p)) `(concat ,(bib-translate "pp. ")
69 (else `(concat ,(bib-translate "pp. ")
70 ,(list-ref p 1) "--" ,(list-ref p 2))))))
72 (tm-define (format-vol-num-pages x)
73 (:mode bib-elsart-num?)
74 (let* ((j (bib-field x "journal"))
75 (v (bib-field x "volume"))
76 (n `(concat "(" ,(bib-field x "number") ")"))
77 (y `(concat "(" ,(bib-field x "year") ")"))
78 (p (let* ((pp (bib-field x "pages")))
80 ((equal? 1 (length pp)) "")
81 ((equal? 2 (length pp)) (list-ref pp 1))
82 (else `(concat ,(list-ref pp 1) "--" ,(list-ref pp 2)))))))
83 (new-list " " `(,j ,v ,n ,y ,p))))
85 (tm-define (format-article n x)
86 (:mode bib-elsart-num?)
87 `(concat ,(format-bibitem n x)
88 (label ,(string-append "bib-" (list-ref x 2)))
92 ,(format-field-Locase x "title")
93 ,@(if (bib-empty? x "crossref")
94 `(,(format-vol-num-pages x))
95 `((concat ,(bib-translate "in ")
96 (cite ,(bib-field x "crossref")))
98 ,(format-field x "note"))))))
100 (tm-define (format-book n x)
101 (:mode bib-elsart-num?)
102 `(concat ,(format-bibitem n x)
103 (label ,(string-append "bib-" (list-ref x 2)))
106 `(,(if (bib-empty? x "author")
109 ,(format-field x "title")
111 ,@(if (bib-empty? x "crossref")
112 `(,(format-volume-or-number x)
113 ,(format-field x "publisher")
114 ,(format-field x "address"))
115 `((concat ,(bib-translate "in ")
116 (cite ,(bib-field x "crossref")))
117 ,(format-edition x )))
118 ,(format-field x "year")
119 ,(format-field x "note"))))))
121 (tm-define (format-booklet n x)
122 (:mode bib-elsart-num?)
123 `(concat ,(format-bibitem n x)
124 (label ,(string-append "bib-" (list-ref x 2)))
128 ,(format-field-Locase x "title")
129 ,(format-field x "howpublished")
130 ,(format-field x "address")
131 (concat ,(if (bib-empty? x "note")
133 `(concat ,(format-field x "note") " "))
134 "(" ,(format-date x) ")"))))))
136 (tm-define (format-inbook n x)
137 (:mode bib-elsart-num?)
138 `(concat ,(format-bibitem n x)
139 (label ,(string-append "bib-" (list-ref x 2)))
142 `(,(if (bib-empty? x "author")
145 ,(format-field x "title")
146 ,@(if (bib-empty? x "crossref")
147 `(,(format-edition x)
148 ,(format-volume-or-number x)
149 ,(format-field x "publisher")
150 ,(format-field x "address")
151 ,(format-field x "year")
152 ,(format-chapter-pages x))
153 `((concat ,(bib-translate "in ")
154 (cite ,(bib-field x "crossref")))
155 ,(format-field x "edition")
156 ,(format-field x "year")))
157 ,(format-field x "note"))))))
159 (tm-define (format-incollection n x)
160 (:mode bib-elsart-num?)
161 `(concat ,(format-bibitem n x)
162 (label ,(string-append "bib-" (list-ref x 2)))
166 ,(format-field-Locase x "title")
167 ,@(if (bib-empty? x "crossref")
168 `((concat ,(bib-translate "in: ")
170 ,(format-field x "booktitle")
172 ,(format-volume-or-number x)
173 ,(format-field x "publisher")
174 ,(format-field x "address")
175 ,(format-field x "year"))
176 `((concat ,(bib-translate "in ")
177 (cite ,(bib-field x "crossref")))))
178 ,(format-chapter-pages x)
179 ,(format-field x "note"))))))
181 (tm-define (format-inproceedings n x)
182 (:mode bib-elsart-num?)
183 (format-incollection n x))
185 (tm-define (format-manual n x)
186 (:mode bib-elsart-num?)
187 `(concat ,(format-bibitem n x)
188 (label ,(string-append "bib-" (list-ref x 2)))
191 `(,@(if (bib-empty? x "author")
192 (if (bib-empty? x "organization")
194 `(,(format-field x "organization")
195 ,(format-field x "address")))
196 `(,(format-author x)))
197 ,(format-field x "title")
198 ,(format-field x "organization")
199 ,(format-field x "address")
201 (concat ,(if (bib-empty? x "note")
203 `(concat ,(format-field x "note") " "))
204 "(" ,(format-date x) ")"))))))
206 (tm-define (format-mastersthesis n x)
207 (:mode bib-elsart-num?)
208 `(concat ,(format-bibitem n x)
209 (label ,(string-append "bib-" (list-ref x 2)))
213 ,(format-field-Locase x "title")
214 ,(if (bib-empty? x "type")
215 ,(bib-translate "Master's thesis")
216 (format-field x "type"))
217 ,(format-field x "school")
218 ,(format-field x "address")
219 (concat ,(if (bib-empty? x "note")
221 `(concat ,(format-field x "note") " "))
222 "(" ,(format-date x) ")"))))))
224 (tm-define (format-misc n x)
226 `(concat ,(format-bibitem n x)
227 (label ,(string-append "bib-" (list-ref x 2)))
231 ,(format-field-Locase x "title")
232 ,(format-field x "howpublished")
233 (concat ,(if (bib-empty? x "note")
235 `(concat ,(format-field x "note") " "))
236 "(" ,(format-date x) ")"))))))
238 (tm-define (format-phdthesis n x)
239 (:mode bib-elsart-num?)
240 (format-mastersthesis n x))
242 (tm-define (format-proceedings n x)
243 (:mode bib-elsart-num?)
244 `(concat ,(format-bibitem n x)
245 (label ,(string-append "bib-" (list-ref x 2)))
248 `(,(if (bib-empty? x "editor")
249 (format-field x "organization")
251 ,(format-field x "title")
252 ,(format-volume-or-number x)
253 ,(if (bib-empty? x "editor")
255 (format-field x "organization"))
256 ,(format-field x "publisher")
257 ,(format-field x "address")
258 ,(format-field x "year")
259 ,(format-field x "note"))))))
261 (tm-define (format-techreport n x)
262 (:mode bib-elsart-num?)
263 `(concat ,(format-bibitem n x)
264 (label ,(string-append "bib-" (list-ref x 2)))
268 ,(format-field-Locase x "title")
269 ,(format-tr-number x)
270 ,(format-field x "institution")
271 ,(format-field x "address")
272 (concat ,(if (bib-empty? x "note")
274 `(concat ,(format-field x "note") " "))
275 "(" ,(format-date x) ")"))))))
277 (tm-define (format-unpublished n x)
278 (:mode bib-elsart-num?)
279 `(concat ,(format-bibitem n x)
280 (label ,(string-append "bib-" (list-ref x 2)))
284 ,(format-field-Locase x "title")
285 (concat ,(if (bib-empty? x "note")
287 `(concat ,(format-field x "note") " "))
288 "(" ,(format-date x) ")"))))))