Skip to content

Commit

Permalink
[fix] equation numbering with circuits (#4)
Browse files Browse the repository at this point in the history
When equation numbering is turned on, display-style braces as used with lstick, rstick and gate inputs/outputs, are not drawn correctly.

We could use non-block math but then the bounding box of the rectangles is not measured correctly. Instead we just turn equation numbering off for the entire circuit.

fixes #3
  • Loading branch information
Mc-Zen authored Mar 31, 2024
1 parent 1816c38 commit 1bed08a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
13 changes: 7 additions & 6 deletions src/draw-functions.typ
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@



// create a sized brace with given length.
// Creates a sized brace with given length.
// `brace` can be auto, defaulting to "{" if alignment is right
// and "}" if alignment is left.
// and "}" if alignment is left. Other possible values are
// "[", "]", "|", "{", and "}".
#let create-brace(brace, alignment, length) = {
let brace-symbol = if brace == auto {
if alignment == right {"{"} else {"}"}
} else { brace }
return $ lr(#brace-symbol#block(height: length)) $
if brace == auto {
brace = if alignment == right {"{"} else {"}"}
}
return $ lr(#brace, size: length) $
}


Expand Down
3 changes: 2 additions & 1 deletion src/quill.typ
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
panic("Unexpected named argument '" + children.named().keys().at(0) + "' for quantum-circuit()")
}
set text(color, size: font-size)

set math.equation(numbering: none)

style(styles => {

// Parameter object to pass to draw-function containing current style info
Expand Down
Binary file added tests/decorations/lstick rstick/ref/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion tests/decorations/lstick rstick/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@

#quantum-circuit(
1, rstick("very long rstick")
)
)

#pagebreak()

// lstick with equation numbering
#set math.equation(numbering: "1")
#quantum-circuit(
lstick($|0〉$, brace: "{"), 1
)

0 comments on commit 1bed08a

Please sign in to comment.