Skip to content

Support common notations in circuit_to_latex_using_qcircuit #4685

@fedimser

Description

@fedimser

Is your feature request related to a use case or problem? Please describe.
There are common notations for some gates supported by QCircuit, but Cirq's circuit_to_latex_using_qcircuit doesn't use them. This includes:

  • SWAP gate which rendered as rectangle with "SWAP" inside it, instead of two crosses connected by a line.
  • Multi-controlled X gate, where some controls are "1" and some are "0". Conventional notation for "0" controls is unfilled circle.

Describe the solution you'd like
Add special handling for common conventional notations (supported by QCircuit) to circuit_to_latex_using_qcircuit.

[optional] Describe alternatives/workarounds you've considered
I wrote a find-and-replace post-processing script which produces desired result in my case:

def process_latex(s):
    s = s.replace('\\multigate{1}{\\text{SWAP}}', '\\qswap')
    s = s.replace('\\ghost{\\text{SWAP}}', '\\qswap\\qwx')
    s = s.replace('\\gate{\\text{@}}','\\control')
    s = s.replace('\\gate{\\text{(0)}}','\\ctrlo{}')
    s = s.replace('\\gate{\\text{X}}','\\targ')
    while '   ' in s:
        s = s.replace('   ', ' ')
    return s

[optional] Additional context (e.g. screenshots)
Example of circuit, its current rendering and desired rendering (which was obtained with a script above):

Screenshot from 2021-11-14 09-30-23

What is the urgency from your perspective for this issue? Is it blocking important work?
P3

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/latexarea/qcircuitarea/visualizationgood first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.kind/feature-requestDescribes new functionalityno QC knowledge neededWant to contribute to Cirq, but don't know quantum computing? This issue is for you.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions