Skip to content

Commit 596d478

Browse files
committed
Explicit paren in an application uses left and right parens
1 parent 18e5077 commit 596d478

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

racket-cas/format.rkt

+20-10
Original file line numberDiff line numberDiff line change
@@ -727,11 +727,15 @@
727727
(~a "\\int " (v~ u) "\\ \\textrm{d}" (v~ v))])] ; TODO: only for TeX
728728

729729
; applications
730-
[(app: f us) (let ()
731-
(define arguments
732-
(string-append* (add-between (map v~ us) ",")))
733-
(define head ((output-format-function-symbol) f))
734-
(~a head app-left arguments app-right))]
730+
[(app: f us) (match us
731+
[(list (list 'paren us ...))
732+
(define arguments (apply string-append (add-between (map v~ us) ",")))
733+
(define head ((output-format-function-symbol) f))
734+
(~a head "\\left"app-left arguments "\\right" app-right)]
735+
[_
736+
(define arguments (apply string-append (add-between (map v~ us) ",")))
737+
(define head ((output-format-function-symbol) f))
738+
(~a head app-left arguments app-right)])]
735739
[_ (wrap u)]))
736740
(define (t1~ u) ; term 1 aka first term in a sum
737741
(when debugging? (displayln (list 't1 u)))
@@ -1031,11 +1035,15 @@
10311035

10321036
[(app: f us) #:when (memq f '(< > ≤ ≥ <= >= Less LessEqual Greater GreaterEqual))
10331037
(match us [(list u v) (~a (v~ u) (~relop f) (v~ v))])]
1034-
[(app: f us) (let ()
1035-
(define arguments
1036-
(apply string-append (add-between (map v~ us) ",")))
1037-
(define head ((output-format-function-symbol) f))
1038-
(~a head app-left arguments app-right))]
1038+
[(app: f us) (match us
1039+
[(list (list 'paren us ...))
1040+
(define arguments (apply string-append (add-between (map v~ us) ",")))
1041+
(define head ((output-format-function-symbol) f))
1042+
(~a head "\\left"app-left arguments "\\right" app-right)]
1043+
[_
1044+
(define arguments (apply string-append (add-between (map v~ us) ",")))
1045+
(define head ((output-format-function-symbol) f))
1046+
(~a head app-left arguments app-right)])]
10391047
[_ (display u)
10401048
(error 'verbose~ (~a "internal error, got: " u))]))
10411049

@@ -1201,4 +1209,6 @@
12011209
(check-equal? (tex '(* 2 (up 3 4))) "$2\\begin{pmatrix} 3\\\\4\\end{pmatrix}$")
12021210
(check-equal? (tex '(+ (* 2 (up 3 4)) (vec b))) "$2\\begin{pmatrix} 3\\\\4\\end{pmatrix}+\\vec{b}$")
12031211
(check-equal? (tex '(+ (* 2 (up 3 4)) (vec AB))) "$2\\begin{pmatrix} 3\\\\4\\end{pmatrix}+\\overrightarrow{AB}$")
1212+
; explicit paren in a function application means parens using \left and \right
1213+
(check-equal? (tex '(f (paren x y))) "$f\\left(x,y\\right)$")
12041214
)

0 commit comments

Comments
 (0)