Repository: Qiskit/qiskit

Issue:
latex drawer: justifying doesn't work for custom gates
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues to confirm this idea does not exist. -->

### What is the expected enhancement?
Boxes get overlapped in the latex drawer. In the example below I have 3 boxes: a 1-qubit unitary, a 2-qubit unitary, and a 2-qubit custom opaque gate.

```python
from qiskit.circuit import QuantumRegister, QuantumCircuit
from qiskit.circuit import Gate
from qiskit.quantum_info.random import random_unitary
qr = QuantumRegister(3)
qc = QuantumCircuit(qr)
U1 = random_unitary(2)
U2 = random_unitary(4)
opaque_gate = Gate(name='opaque_gate', num_qubits=2, params=[])
qc.append(U1, [qr[1]])
qc.append(U2, [qr[0], qr[1]])
qc.append(opaque_gate, [qr[1], qr[2]])
qc.draw(output='latex', justify='left')
```

![image](https://user-images.githubusercontent.com/8622381/56903233-ddfd8300-6a69-11e9-8810-537e3c51d1e1.png)


Maybe an issue with justification? Though I was not able to fix this by tweaking the `justify` param.

PS. The underscore in the opaque_gate name should also render better.


Discussion:

Resolving patch:
diff --git a/qiskit/visualization/latex.py b/qiskit/visualization/latex.py
--- a/qiskit/visualization/latex.py
+++ b/qiskit/visualization/latex.py
@@ -298,7 +298,6 @@ def _build_latex_array(self, aliases=None):
         the current qubits in the circuit to new qubit names.
         We will deduce the register names and sizes from aliases.
         """
-        columns = 1
 
         # Rename qregs if necessary
         if aliases:
@@ -377,7 +376,7 @@ def _build_latex_array(self, aliases=None):
                                 self._latex[pos_1][column] = "\\gate{R_z(%s)}" % (
                                     op.op.params[0])
                             else:
-                                self._latex[pos_1][columns] = "\\gate{%s}" % nm
+                                self._latex[pos_1][column] = "\\gate{%s}" % nm
 
                             gap = pos_2 - pos_1
                             for i in range(self.cregs[if_reg]):
@@ -436,7 +435,7 @@ def _build_latex_array(self, aliases=None):
                                     "\\push{\\rule{.6em}{0em}\\ket{0}\\"
                                     "rule{.2em}{0em}} \\qw")
                             else:
-                                self._latex[pos_1][columns] = "\\gate{%s}" % nm
+                                self._latex[pos_1][column] = "\\gate{%s}" % nm
 
                     elif len(qarglist) == 2:
                         pos_1 = self.img_regs[(qarglist[0][0], qarglist[0][1])]
@@ -546,14 +545,14 @@ def _build_latex_array(self, aliases=None):
                                 stop_pos = max([pos_1, pos_2])
                                 if stop_pos - start_pos >= 2:
                                     delta = stop_pos - start_pos
-                                    self._latex[start_pos][columns] = (
+                                    self._latex[start_pos][column] = (
                                         "\\multigate{%s}{%s}" % (delta, nm))
                                     for i_pos in range(start_pos + 1, stop_pos + 1):
-                                        self._latex[i_pos][columns] = "\\ghost{%s}" % nm
+                                        self._latex[i_pos][column] = "\\ghost{%s}" % nm
                                 else:
-                                    self._latex[start_pos][columns] = (
+                                    self._latex[start_pos][column] = (
                                         "\\multigate{1}{%s}" % nm)
-                                    self._latex[stop_pos][columns] = "\\ghost{%s}" % nm
+                                    self._latex[stop_pos][column] = "\\ghost{%s}" % nm
 
                     elif len(qarglist) == 3:
                         pos_1 = self.img_regs[(qarglist[0][0], qarglist[0][1])]
@@ -635,15 +634,15 @@ def _build_latex_array(self, aliases=None):
                                 stop_pos = max([pos_1, pos_2, pos_3])
                                 if stop_pos - start_pos >= 3:
                                     delta = stop_pos - start_pos
-                                    self._latex[start_pos][columns] = (
+                                    self._latex[start_pos][column] = (
                                         "\\multigate{%s}{%s}" % (delta, nm))
                                     for i_pos in range(start_pos + 1, stop_pos + 1):
-                                        self._latex[i_pos][columns] = "\\ghost{%s}" % nm
+                                        self._latex[i_pos][column] = "\\ghost{%s}" % nm
                                 else:
-                                    self._latex[pos_1][columns] = (
+                                    self._latex[pos_1][column] = (
                                         "\\multigate{2}{%s}" % nm)
-                                    self._latex[pos_2][columns] = "\\ghost{%s}" % nm
-                                    self._latex[pos_3][columns] = "\\ghost{%s}" % nm
+                                    self._latex[pos_2][column] = "\\ghost{%s}" % nm
+                                    self._latex[pos_3][column] = "\\ghost{%s}" % nm
 
                     elif len(qarglist) > 3:
                         nbits = len(qarglist)
@@ -655,10 +654,10 @@ def _build_latex_array(self, aliases=None):
                         pos_start = min(pos_array)
                         pos_stop = max(pos_array)
                         delta = pos_stop - pos_start
-                        self._latex[pos_start][columns] = (
+                        self._latex[pos_start][column] = (
                             "\\multigate{%s}{%s}" % (nbits - 1, nm))
                         for pos in range(pos_start + 1, pos_stop + 1):
-                            self._latex[pos][columns] = "\\ghost{%s}" % nm
+                            self._latex[pos][column] = "\\ghost{%s}" % nm
 
                 elif op.name == "measure":
                     if (len(op.cargs) != 1


Test patch: