Closed tigerjack closed 2 years ago
I would say that the main issue here is not the missing highlighting, but the missing anything (there are no gates at all). This is due to the fact that you mix TeX commands (\only
) with yquant commands. While this is in general possible, you must be careful to restart the yquant parser after every set of macros (saying \yquant
).
Background: Due to the nature of TeX macros and expansion, it is not possible to do this automatically for any arbitrary macro. However, it is possible for very specific macros where we know the exact definition - this is the reason why yquant will automatically take care of this whenever you use TikZ macros (such as \draw
, \fill
, ...). But this automatism is not implemented for beamer macros - though I think this might be a very meaningful addition.
While I would definitely consider implementing it, the situation that you gave is probably also the best showcase of how such an automatism would probably fail. The attributes of a yquant gate command and the gate itself belong together and cannot be split; however, this is precisely what you do here. So if I were to implement an automatism, you would have to write the gate commands twice - once with and once without attributes. Without this automatism, you can actually hack it together to work:
qubit q[2];
\alt<2>{\yquant [fill=red]}{\yquant}
h q[0];
cnot q[1] | q[0];
Here, I restart the yquant parser both after the execution of the \only
part (and due to the way of how \alt
expands, the second braced content will be completely removed from the input stream, so it is actually not present on the second slide) and also after all the other slides.
I have to check all the beamer macros whether there is a meaningful way to construct a workaround such as in this case, as the naive way to map \only<x>{y}
to something as \only<x>{\yquant y}\yquant
, will completely break things in this case.
Thanks again @projekter, I confirm it works like a charm. I am wondering if this mechanism would work also for "undiscovering" layers of the circuit (i.e., layers of gates) once at a time, but maybe this will be the object of another question in the future.
I do not have such a good knowledge of tex/beamer macros to provide an adequate reply on that. I let you decide if to close the issue or to keep it open to have a reference for your implementation of the workaround.
The current master contains new updates that should make the integration with beamer much more easy. In particular, what you wrote in your first post should now work as expected without all the parser issues. I created patches for \only
, \alt
, \temporal
, \uncover
, \visible
, \invisible
, and \note
(well, these are non-intrusive patches: I don't change the macros, but if the yquant parser recognizes one of those macros, it will take special care.
Also \onslide
and \pause
should in principle work with simple circuits, although there are no guarantees for more complex ones (as also states in the beamer manual itself, so I'm fine with this).
The beamer integration is documented in the new section 8.2. I would appreciate some testing in real-live use cases before this goes to the CTAN.
Describe the bug When I introduce overlay commands in yquant, the output is inconsistent.
To Reproduce
Expected output For this specific example, I expect the
H
gate to have a red color on the second slide.Screenshots Output of previous code![image](https://user-images.githubusercontent.com/8199216/137785892-43263e6a-b83e-4854-8cb7-b96b43e6624a.png)
Environment
pdflatex