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

latex-source (and latex) circuit drawer support for standalone (and cleaner output) #6483

Merged
merged 16 commits into from
Jun 25, 2021

Conversation

JoshDumo
Copy link
Contributor

@JoshDumo JoshDumo commented May 29, 2021

Summary

fixes #6447 and some of CQuIC/qcircuit#41

Details and comments

circuit.draw("latex_source") was not using standalone, so the output was a full page. Also had some several optional lines cluttering the tex code output.
Modified latex.py to make the latex drawer use standalone. Removed any extra output lines of tex code.
To deal with cropping, hacked the output by adding nghost{} with the name of the qubit to give extra tabbing before the labels. Also added a new line at the top and the bottom of the Qcircuit.
Generated new Test tex files according to the new tex code output program.

@JoshDumo JoshDumo requested review from nkanazawa1989, nonhermitian and a team as code owners May 29, 2021 00:36
@CLAassistant
Copy link

CLAassistant commented May 29, 2021

CLA assistant check
All committers have signed the CLA.

@1ucian0
Copy link
Member

1ucian0 commented May 29, 2021

nice hack! (I just took the freedom of blacking and removing the commented lines, have a look and feel free to revert)

@TharrmashasthaPV
Copy link
Contributor

Nicely done @JoshDumo . I just have one small observation. When the initial_state is set to True in the drawer, the label seems to get pushed back and cropped. For instance

qc = QuantumCircuit(2)
qc.h([0])
qc.cx(0,1)
qc.draw('latex', initial_state=True)

gives an output like

image

Could you please check on that?

Copy link
Contributor

@TharrmashasthaPV TharrmashasthaPV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @JoshDumo . The output looks good now. I just had a few pointers.

qiskit/visualization/latex.py Show resolved Hide resolved
qiskit/visualization/latex.py Outdated Show resolved Hide resolved
qiskit/visualization/latex.py Outdated Show resolved Hide resolved
@TharrmashasthaPV
Copy link
Contributor

Thanks @JoshDumo . The fix looks great! Nice find on the scaling. Blacking should help pass the tests.

@javabster javabster added the Changelog: New Feature Include in the "Added" section of the changelog label Jun 24, 2021
@1ucian0 1ucian0 changed the title fixed issue 6447 to use standalone and fewer cleaner lines latex-source (and latex) support for standalone (and cleaner output) Jun 24, 2021
Copy link
Member

@1ucian0 1ucian0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@1ucian0 1ucian0 changed the title latex-source (and latex) support for standalone (and cleaner output) latex-source (and latex) circuit drawer support for standalone (and cleaner output) Jun 24, 2021
@mergify mergify bot merged commit d9c3d55 into Qiskit:main Jun 25, 2021
TharrmashasthaPV added a commit to TharrmashasthaPV/qiskit-terra that referenced this pull request Jun 28, 2021
mergify bot pushed a commit that referenced this pull request Sep 23, 2021
…conditioning (#6248)

* Cbit conditional

* lint fixed

* q

* added_tests

* Added tests

* lint fix

* lint-fix

* added extra test

* latex drawer for single bit cond

* fixed small errors

* Minor fix

* Added extra test

* Added reno and a small lint fix

* Fixed reno

* lint fix

* References refactored for #6483

* Suggested changes

* Corrected failing test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: New Feature Include in the "Added" section of the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Get "cleaner" tex code from QuantumCircuit.draw('latex_source')
5 participants