Mc-Zen / quill

Effortlessly create quantum circuit diagrams in Typst.
https://typst.app/universe/package/quill
MIT License
40 stars 2 forks source link

make midstick behavior similar to lstick and rstick #2

Closed maxtremblay closed 7 months ago

maxtremblay commented 7 months ago

Hello, thanks for this great package.

I have some trouble with midstick and fill color. I have set the option

#quantum-circuit(
    fill: accent-color,
    midstick($ket(Omega_1)$),
    mqgate($hat(U)(tau_1, hat(P)_1)$, n: 4),
    ...

)

As you can see, the labels from midstick are filled with a red background which I would prefer to avoid.

screenshot_02282024_09_44_53

I can use lstick instead, but in that case, the kets and dots are not aligned.

screenshot_02282024_09_49_11

Mc-Zen commented 7 months ago

Hi @maxtremblay ,

I'm glad you find the package useful :)

This is practically a duplicate of #1 . midstick is basically implemented as a gate but without a border around the box. The reason is that gates need to overdraw the quantum (or classical) wires (see second screenshot in this issue: #1). However, it would make much sense that the fill property for quantum-circuit() would not apply to midstick, so that midstick continues using the circuit background color (defaulting to white). This way, midstick would behave as you suggested.

Edit: see comment below

I will change that. Until the next release, you can work around this issue by declaring

#let gate = gate.with(fill: accent-color)
#let mqgate = mqgate.with(fill: accent-color)

and omitting the fill argument for quantum-circuit.

I hope this helps.

Mc-Zen commented 7 months ago

Also: in the (rather near) future, (when user-defined types are added to Typst), gate will become an "element". The fill parameter will then be deprecated for quantum-circuit and you can instead write

#set gate(fill: accent-color)

which is much more flexible. Just so you know

Mc-Zen commented 7 months ago

Edit: I read up the docs for quill and actually this:

#let gate = gate.with(fill: accent-color)
#let mqgate = mqgate.with(fill: accent-color)

is the intended way to go (until the aforementioned change). The quantum-circuit(fill: ) parameter just changes the default fill for all kinds of gate-like elements so that a circuit can be put on some single-color background that is not white. I have to admit though, this is not very clear from the docs.

maxtremblay commented 7 months ago

Ok. Thank you for the solution. I will go with that for now :smile: