Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce space between rendered rules of a judgement form #264

Open
o6po5fcs opened this issue Jun 29, 2023 · 3 comments
Open

Reduce space between rendered rules of a judgement form #264

o6po5fcs opened this issue Jun 29, 2023 · 3 comments

Comments

@o6po5fcs
Copy link

o6po5fcs commented Jun 29, 2023

I have quite a large judgment form to be rendered for a paper, and I would like to somewhat compact it by reducing the space between the different rules. A standalone excerpt of the judgment form can be found below. To demonstrate, I set all of the "spacing" parameters that I could find to 0, even when they do not affect the rendering of judgment forms.

As a sidenote, I have noticed that, in some cases, the parameter horizontal-bar-spacing reduces only the space above a horizontal bar, and not below. In the screenshot below the code I highlighted one such instance with a red arrow. Possibly related to the inclusion of a unicode union character in the bottom line?

#lang racket

(require redex
         redex/pict)
(define-language CommonLang
  (k ::= number i)
  (p ::= (k ...)) 
  (p-exp ::= k * [script-op (~ k ...)] [script-op k] [⋃ k ...]))

(define-judgment-form
  CommonLang
  #:mode     (matches-in-env I I I)
  #:contract (matches-in-env ps p env)
  
  [--------------------------------- "empty-selector"
   (matches-in-env () () env)]
  [(matches-in-env (p-exp ...) (k_2 ...) env)
   --------------------------------- "literal-key"
   (matches-in-env (k_1 p-exp ...) (k_1 k_2 ...) env)]
  [(matches-in-env (k_1 p-exp ...) (k_2 ...) env)
   --------------------------------- "union-first"
   (matches-in-env ([⋃ k_1 k_3 ...] p-exp ...) (k_2 ...) env)])

(define (render-matches-in-env . filepath)
  (arrow-space 0)
  (label-space 0)
  (reduction-relation-rule-separation 0) 
  (reduction-relation-rule-extra-separation 0)
  (reduction-relation-rule-line-separation 0)
  (horizontal-bar-spacing 0)
  (metafunction-gap-space 0)
  (metafunction-rule-gap-space 0)
  (metafunction-line-gap-space 0)

  (if (empty? filepath)
      (render-judgment-form matches-in-env)
      (render-judgment-form matches-in-env (car filepath))))

The space that I wish to somewhat reduce highlighted with a red bar, and an instance of horizontal-bar-spacing not respecting being set to 0 is highlighted with a red arrow.

annotated-space

@rfindler
Copy link
Member

rfindler commented Jun 29, 2023 via email

@o6po5fcs
Copy link
Author

Alright, thank you for the quick response! I had hoped to (as much as possible) make the figures easy to reproduce in code, but in this specific instance it is probably much faster to edit the pdf in Adobe Illustrator to reposition the rules.

For my part the issue can be closed, but I will keep it open for now in case the horizontal-bar-spacing thing is something someone wants to address.

@rfindler
Copy link
Member

The disadvantage to using adobe is that you'll have to redo that work when the rules change and it can be easy to forget to do. If you're using scribble to write the document itself, you can just drop picts in anywhere (eg in a figure) and then building the paper will always just use the latest version of the redex code. Here's how you can eliminate the blank space between the clauses, for example.

#lang racket
(require redex pict)
(define-language L
  (e ::= (e e) (λ (x) e) x)
  (x ::= variable-not-otherwise-mentioned))

(define-judgment-form L
  #:mode (fv I O)
  #:contract (fv e (x ...))

  [(fv e_1 (x_1 ...)) (fv e_2 (x_2 ...))
   ------------------------------- "app"
   (fv (e_1 e_2) (x_1 ... x_2 ...))]

  [------------------------------- "var"
   (fv x (x))]

  [(fv e (x_2 ...))
   ------------------------------- "lam"
   (fv (λ (x_1) e) (rm (x_2 ...) x_1))])

(define-metafunction L
  rm : (x ...) x -> (x ...)
  [(rm () x) ()]
  [(rm (x_1 x_2 ...) x_1) (rm (x_2 ...) x_1)]
  [(rm (x_1 x_2 ...) x_3)
   (x_1 x_4 ...)
   (where (x_4 ...) (rm (x_2 ...) x_3))])

(define (render-fv-case name)
  (parameterize ([judgment-form-cases
                  (list name)])
    (render-judgment-form fv)))

(render-judgment-form fv)

(vc-append
 (render-fv-case "app")
 (render-fv-case "var")
 (render-fv-case "lam"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants