# Saving vectorized circuits in Qiskit

Is there a way to save vectorized images in Qiskit? I am using

circuit.draw('latex', filename='./file.pdf')


They type of the image is a pdf, but it looks like a png exported as a pdf. For reference I attach here a figure of the differences I point out.

Hopefully some differences can be noticed. The top subfigure was made with Quantikz, while the other directly with Qiskit. The difference that the top is vectorized and the other looks like it isn't.

EDIT:

The problem is solved using what luciano pointed out. I just want to add that the resulting pdf circuit may still need some cleaning. Apparently the figure is not "tight framed", I attach an example of what I mean

The letters that appear at the bottom are part of the figure caption. One can see that there's a huge space between the image and the caption, along with a border that frames the image.

With 'latex_source' you can save the LaTeX file and compile it later with pdflatex

In an interactive console (such a Jupyter notebook), you can run the following:

circuit.draw('latex_source', filename='./file.tex')
!pdflatex file.tex


This will create a file.pdf in actual PDF format.

(I understand this is very unintuitive, I submitted a fix to it)

• Ah I see, thanks. The docs are a little bit confusing in this part. I will add some extra feature that I find, hopefully this can also be corrected in the upcoming patches. May 20, 2021 at 9:22
• if you need to insert the circuit image in another latex file, you can paste the relevant part of latex_source output in it. May 20, 2021 at 12:22
• Ok, I just thought that something similar to bbox_inches='tight' could be made here (it could help when writting thesis or papers). May 20, 2021 at 13:05