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

Circuit.to_latex_file generates invalid LaTeX for register names containing underscores #1363

Closed
CalMacCQ opened this issue Apr 25, 2024 · 1 comment · Fixed by #1385
Closed
Assignees
Labels
bug Something isn't working

Comments

@CalMacCQ
Copy link
Contributor

CalMacCQ commented Apr 25, 2024

The Circuit.to_latex_file method seems to produce invalid LaTeX if the names of the registers contain underscores.

Build circuit

from pytket import Circuit
from pytket.circuit.display import render_circuit_jupyter as draw

circ = Circuit()

s = circ.add_q_register("s_register", 2)
l = circ.add_q_register("l_register", 3)

circ.CCX(s[0], l[1], l[2])
circ.CRy(0.75, s[1], l[1])
circ.CRx(0.71, l[0], s[1])

draw(circ)

latex_circuit

export to LaTeX

circ.to_latex_file( "test.tex")

I get the following ouput

\documentclass[tikz]{standalone}
\usetikzlibrary{quantikz}
\begin{document}
\begin{quantikz}
\lstick{l_register[0]} & \qw & \qw & \ctrl{4} & \qw \\
\lstick{l_register[1]} & \ctrl{1} & \gate{\text{$R_Y$(0.75)}} & \qw & \qw \\
\lstick{l_register[2]} & \targ{} & \qw & \qw & \qw \\
\lstick{s_register[0]} & \ctrl{-1} & \qw & \qw & \qw \\
\lstick{s_register[1]} & \qw & \ctrl{-3} & \gate{\text{$R_X$(0.71)}} & \qw \\
\end{quantikz}
\end{document}

This LaTeX doesn't compile. If I manually remove the underscores then it compiles and I get a circuit diagram. Seems the underscored names are casuing an issue.

I also get a warning noting that we use Quantikz rather than Quantikz2.

@CalMacCQ CalMacCQ added the bug Something isn't working label Apr 25, 2024
@Ismail-Quantinuum
Copy link

Thanks for this Callum! Yes and since the warning is so unhelpful, it leaves one at a complete loss for what they did wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants