Repository: Qiskit/qiskit

Issue:
increase spacing of parameters in latex drawer
QISKit's visualization module is not properly drawing the **cu1** gate. With the following code,

```
from qiskit import QuantumProgram
from qiskit.tools.visualization import circuit_drawer

qp = QuantumProgram()
qr = qp.create_quantum_register('qr', 3)
cr = qp.create_classical_register('cr', 1)
qc = qp.create_circuit('test', [qr], [cr])
qc.cu1(2.3, qr[0], qr[2])
qc.measure(qr[1], cr[0])

circuit_drawer(qc)
```

The obtained image is,

![test](https://user-images.githubusercontent.com/14854311/43361593-84621eb8-92ca-11e8-8300-91680d2489ce.png)

Which is clearly corrupt.

### Informations

- **Qiskit (Python SDK) version**: 0.5.7
- **Python version**: 3.6.6
- **Operating system**: Ubuntu 18.04.1 LTS


Discussion:
It is correct but it needs more space before the measurement. 
It also happens without the measurement.
Hi @cruzpmmq 

I am not sure what you think is incorrect. The number is the phase that is added if both qubits are in the 1 state. I agree that in the picture you uploaded it is too far away and looks like it is part of the measurement. 
Hi @jaygambetta 

I was expecting the usual boxed notation for controlled operations. Also, the following snippet implements the fourier transform on three qubits and the figure representation doesn't look so nice...

```
from qiskit import QuantumProgram
from qiskit.tools.visualization import circuit_drawer
from numpy import pi

qp = QuantumProgram()

qr = qp.create_quantum_register('qr', 3)
qc = qp.create_circuit('qc', [qr])

c_rk = lambda k, ctl, tgt: qc.cu1(2*pi/(2**k), ctl, tgt)

qc.h(qr[0])
c_rk(2, qr[1], qr[0])
c_rk(3, qr[2], qr[0])
qc.h(qr[1])
c_rk(2, qr[1], qr[2])
qc.h(qr[2])

circuit_drawer(qc)
```

![test2](https://user-images.githubusercontent.com/14854311/43362017-d3fe2086-92d7-11e8-90b2-b35dff9adc2e.png)
@cruzpmmq the CU1 gate is symmetric. So this is the correct notation. A boxed notation would imply that control and target are different. 

I agree the angles should be spaced out better. It is due to latex's column layout where the label of one column runs into the other column. I'll try to adjust it.
@ajavadia 

Ok, I understand. I was just mentioning that because this operation is sometimes represented with a boxed notation (e.g. Fig.5.1 Nielsen & Chuang), and also because cu1() has ctl and tgt parameters. Thanks for looking into it.

By the way, on another subject: One very helpful feature to add to this drawing methods would be to include a parameter for the user to choose if the numbering on the qubits of the diagram goes 0,1,2,.. from top to bottom (as it is) or bottom-up. That would be very helpful.
You may consider to use `matplotlib_circuit_drawer`.

```
from qiskit import QuantumProgram
from qiskit.tools.visualization import matplotlib_circuit_drawer as circuit_drawer
from numpy import pi
%matplotlib inline
%config InlineBackend.figure_format = "svg"

qp = QuantumProgram()

qr = qp.create_quantum_register('qr', 3)
qc = qp.create_circuit('qc', [qr])

c_rk = lambda k, ctl, tgt: qc.cu1(2*pi/(2**k), ctl, tgt)

qc.h(qr[0])
c_rk(2, qr[1], qr[0])
c_rk(3, qr[2], qr[0])
qc.h(qr[1])
c_rk(2, qr[1], qr[2])
qc.h(qr[2])

my_style = {"usepiformat":True}

circuit_drawer(qc, style=my_style)
```

![image](https://user-images.githubusercontent.com/15240898/43374436-a90683f0-93ea-11e8-9800-36797ebc5125.png)

It allows you to write the box-ed control.
Please refer to the tutorial here:
https://nbviewer.jupyter.org/github/Qiskit/qiskit-tutorial/blob/master/reference/tools/matplotlib_circuit_drawer.ipynb

```
from qiskit import QuantumProgram
from qiskit.tools.visualization import matplotlib_circuit_drawer as circuit_drawer
from numpy import pi
%matplotlib inline
%config InlineBackend.figure_format = "jpeg"

qp = QuantumProgram()

qr = qp.create_quantum_register('qr', 3)
qc = qp.create_circuit('qc', [qr])

c_rk = lambda k, ctl, tgt: qc.cu1(2*pi/(2**k), ctl, tgt)

qc.h(qr[0])
c_rk(2, qr[1], qr[0])
c_rk(3, qr[2], qr[0])
qc.h(qr[1])
c_rk(2, qr[1], qr[2])
qc.h(qr[2])

my_style = {"usepiformat":True, "latexdrawerstyle":False}

circuit_drawer(qc, style=my_style)
```

![image](https://user-images.githubusercontent.com/15240898/43375002-73d21c82-93ed-11e8-898b-5da94db0fc57.png)

@diego-plan9  the latex drawer requires latex installation (several GBs) and the installation can be technically difficult for various environment. I suggest we close this issue by making the matplotlib drawer as the default drawer.  
> @diego-plan9 the latex drawer requires latex installation (several GBs) and the installation can be technically difficult for various environment. I suggest we close this issue by making the matplotlib drawer as the default drawer.

Hmm, currently if using `circuit_drawer()`, the latex drawer [is tried first, but falls back to the matplotlib one](https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/tools/visualization/_circuit_visualization.py#L76); and the user can chose which one to use by calling the function invidually (`latex_circuit_drawer()` or `matplotlib_circuit_drawer()`.

Which I think covers the case you mention, if I'm reading it right: if the user is not willing/not able to install latex and the dependencies (which indeed are huge), in practice the matplotlib will be used as "default" when calling `circuit_drawer()`. Does this behaviour map into your request? If not, could you comment on https://github.com/Qiskit/qiskit-terra/issues/612, for general improvements about the circuit drawer as whole?
A summary about this issue:
There is an error in the spacing of `cu1` gate in the LaTeX drawer (as explained in https://github.com/Qiskit/qiskit-terra/issues/693#issuecomment-408645734). @ajavadia "will try to adjust it" (I'm assigning @ajavadia, feel free to remove yourself). Also, @qruzar mentioned the `reversebits` issue, which should be addressed by merged PR #762.
The only thing left to do for this issue is to increase spacing of parameters for better readability. I adjusted the title accordingly.

Resolving patch:
diff --git a/qiskit/visualization/latex.py b/qiskit/visualization/latex.py
--- a/qiskit/visualization/latex.py
+++ b/qiskit/visualization/latex.py
@@ -113,7 +113,7 @@ def __init__(self, qregs, cregs, ops, scale, style=None,
         self.column_separation = 0.5
 
         # em points of separation between circuit row
-        self.row_separation = 0.0
+        self.row_separation = 0
 
         # presence of "box" or "target" determines row spacing
         self.has_box = False
@@ -162,7 +162,7 @@ def latex(self, aliases=None):
 \begin{document}
 \begin{equation*}"""
         qcircuit_line = r"""
-    \Qcircuit @C=%.1fem @R=%.1fem @!R {
+    \Qcircuit @C=%.1fem @R=%.1fem @! {
 """
         output = io.StringIO()
         output.write(header_1)


Test patch: