Skip to content

Commit

Permalink
Remove the math block's indentation from the API docs (Qiskit#1123)
Browse files Browse the repository at this point in the history
Turns out the math blocks (latex expressions between double dollars
`$$`) can't be indented more than once without making the pages not
render. After introducing the MDX components for classes, functions, and
attributes on Qiskit#1026, we can't guarantee only one level of indentation,
and this PR adds a new function to remove the indentation as a
postprocess of all the MDX files.

Example of a math expression that was not rendering before:
![Captura desde 2024-04-03
23-35-05](https://github.com/Qiskit/documentation/assets/47946624/b3ecfb8d-b7c7-40c6-84b1-da0965ec0c15)
  • Loading branch information
arnaucasau authored Apr 4, 2024
1 parent db8a025 commit 0bffa07
Show file tree
Hide file tree
Showing 3,144 changed files with 28,273 additions and 28,122 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 6 additions & 6 deletions docs/api/qiskit/0.19/qiskit.aqua.algorithms.HHL.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ python_api_name: qiskit.aqua.algorithms.HHL

To further explain *truncate\_hermitian* indicates whether or not to truncate matrix and result vector to half the dimension by simply cutting off entries with other indices after the input matrix was expanded to be hermitian following

$$
\begin{split}\begin{pmatrix}
0 & A^\mathsf{H}\\
A & 0
\end{pmatrix}\end{split}
$$
$$
\begin{split}\begin{pmatrix}
0 & A^\mathsf{H}\\
A & 0
\end{pmatrix}\end{split}
$$

where the conjugate transpose of matrix $A$ is denoted by $A^\mathsf{H}$. The truncation of the result vector is done by simply cutting off entries of the upper half.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ python_api_name: qiskit.aqua.components.uncertainty_problems.UnivariatePiecewise

This objective function applies controlled Y-rotation to the target qubit, where the control qubits represent integer value, and rotation approximates a piecewise linear function of the amplitude f:

$$
|x\rangle |0\rangle \mapsto |x\rangle (\sqrt(1 - f(x))|0\rangle + sqrt(f(x))|1\rangle )
$$
$$
|x\rangle |0\rangle \mapsto |x\rangle (\sqrt(1 - f(x))|0\rangle + sqrt(f(x))|1\rangle )
$$

**Parameters**

Expand Down
56 changes: 28 additions & 28 deletions docs/api/qiskit/0.19/qiskit.circuit.library.CCXGate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ python_api_name: qiskit.circuit.library.CCXGate

**Matrix representation:**

$$
\begin{split}CCX q_0, q_1, q_2 =
|0 \rangle \langle 0| \otimes I \otimes I + |1 \rangle \langle 1| \otimes CX =
\begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0
\end{pmatrix}\end{split}
$$
$$
\begin{split}CCX q_0, q_1, q_2 =
|0 \rangle \langle 0| \otimes I \otimes I + |1 \rangle \langle 1| \otimes CX =
\begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0
\end{pmatrix}\end{split}
$$

<Admonition title="Note" type="note">
In Qiskit’s convention, higher qubit indices are more significant (little endian convention). In many textbooks, controlled gates are presented with the assumption of more significant qubits as control, which in our case would be q\_2 and q\_1. Thus a textbook matrix for this gate will be:
Expand All @@ -51,20 +51,20 @@ python_api_name: qiskit.circuit.library.CCXGate
q_2: ──■──
```

$$
\begin{split}CCX\ q_2, q_1, q_0 =
I \otimes I \otimes |0 \rangle \langle 0| + CX \otimes |1 \rangle \langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0
\end{pmatrix}\end{split}
$$
$$
\begin{split}CCX\ q_2, q_1, q_0 =
I \otimes I \otimes |0 \rangle \langle 0| + CX \otimes |1 \rangle \langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\
0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\
0 & 0 & 0 & 0 & 0 & 0 & 1 & 0
\end{pmatrix}\end{split}
$$
</Admonition>

Create new CCX gate.
Expand Down
44 changes: 22 additions & 22 deletions docs/api/qiskit/0.19/qiskit.circuit.library.CHGate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ python_api_name: qiskit.circuit.library.CHGate
**Matrix Representation:**

$$
\begin{split}CH\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + H \otimes |1\rangle\langle 1| =
\frac{1}{\sqrt{2}}
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 1 \\
0 & 0 & 1 & 0 \\
0 & 1 & 0 & -1
\end{pmatrix}\end{split}
$$
$$
\begin{split}CH\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + H \otimes |1\rangle\langle 1| =
\frac{1}{\sqrt{2}}
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 1 \\
0 & 0 & 1 & 0 \\
0 & 1 & 0 & -1
\end{pmatrix}\end{split}
$$

<Admonition title="Note" type="note">
In Qiskit’s convention, higher qubit indices are more significant (little endian convention). In many textbooks, controlled gates are presented with the assumption of more significant qubits as control, which in our case would be q\_1. Thus a textbook matrix for this gate will be:
Expand All @@ -47,17 +47,17 @@ python_api_name: qiskit.circuit.library.CHGate
q_1: ──■──
```

$$
\begin{split}CH\ q_1, q_0 =
|0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes H =
\frac{1}{\sqrt{2}}
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 1 \\
0 & 0 & 1 & -1
\end{pmatrix}\end{split}
$$
$$
\begin{split}CH\ q_1, q_0 =
|0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes H =
\frac{1}{\sqrt{2}}
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 & 1 \\
0 & 0 & 1 & -1
\end{pmatrix}\end{split}
$$
</Admonition>

Create new CH gate.
Expand Down
40 changes: 20 additions & 20 deletions docs/api/qiskit/0.19/qiskit.circuit.library.CRXGate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ python_api_name: qiskit.circuit.library.CRXGate

**Matrix representation:**

$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRX(\lambda)\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + RX(\theta) \otimes |1\rangle\langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & \cos{\th} & 0 & -i\sin{\th} \\
0 & 0 & 1 & 0 \\
0 & -i\sin{\th} & 0 & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRX(\lambda)\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + RX(\theta) \otimes |1\rangle\langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & \cos{\th} & 0 & -i\sin{\th} \\
0 & 0 & 1 & 0 \\
0 & -i\sin{\th} & 0 & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$

<Admonition title="Note" type="note">
In Qiskit’s convention, higher qubit indices are more significant (little endian convention). In many textbooks, controlled gates are presented with the assumption of more significant qubits as control, which in our case would be q\_1. Thus a textbook matrix for this gate will be:
Expand All @@ -43,16 +43,16 @@ python_api_name: qiskit.circuit.library.CRXGate
q_1: ────■────
```

$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRX(\theta)\ q_1, q_0 =
|0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RX(\theta) =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & \cos{\th} & -i\sin{\th} \\
0 & 0 & -i\sin{\th} & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRX(\theta)\ q_1, q_0 =
|0\rangle\langle0| \otimes I + |1\rangle\langle1| \otimes RX(\theta) =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & \cos{\th} & -i\sin{\th} \\
0 & 0 & -i\sin{\th} & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
</Admonition>

Create new CRX gate.
Expand Down
40 changes: 20 additions & 20 deletions docs/api/qiskit/0.19/qiskit.circuit.library.CRYGate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ python_api_name: qiskit.circuit.library.CRYGate
**Matrix representation:**

$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRY(\theta)\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + RY(\theta) \otimes |1\rangle\langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & \cos{\th} & 0 & -\sin{\th} \\
0 & 0 & 1 & 0 \\
0 & \sin{\th} & 0 & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRY(\theta)\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + RY(\theta) \otimes |1\rangle\langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & \cos{\th} & 0 & -\sin{\th} \\
0 & 0 & 1 & 0 \\
0 & \sin{\th} & 0 & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$

<Admonition title="Note" type="note">
In Qiskit’s convention, higher qubit indices are more significant (little endian convention). In many textbooks, controlled gates are presented with the assumption of more significant qubits as control, which in our case would be q\_1. Thus a textbook matrix for this gate will be:
Expand All @@ -44,16 +44,16 @@ python_api_name: qiskit.circuit.library.CRYGate
q_1: ────■────
```

$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRY(\theta)\ q_1, q_0 =
|0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes RY(\theta) =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & \cos{\th} & -\sin{\th} \\
0 & 0 & \sin{\th} & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
$$
\begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}CRY(\theta)\ q_1, q_0 =
|0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes RY(\theta) =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & \cos{\th} & -\sin{\th} \\
0 & 0 & \sin{\th} & \cos{\th}
\end{pmatrix}\end{split}\end{aligned}\end{align}
$$
</Admonition>

Create new CRY gate.
Expand Down
40 changes: 20 additions & 20 deletions docs/api/qiskit/0.19/qiskit.circuit.library.CRZGate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ python_api_name: qiskit.circuit.library.CRZGate

**Matrix representation:**

$$
\begin{split}CRZ(\lambda)\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + RZ(\lambda) \otimes |1\rangle\langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & e^{-i\frac{\lambda}{2}} & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & e^{i\frac{\lambda}{2}}
\end{pmatrix}\end{split}
$$
$$
\begin{split}CRZ(\lambda)\ q_0, q_1 =
I \otimes |0\rangle\langle 0| + RZ(\lambda) \otimes |1\rangle\langle 1| =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & e^{-i\frac{\lambda}{2}} & 0 & 0 \\
0 & 0 & 1 & 0 \\
0 & 0 & 0 & e^{i\frac{\lambda}{2}}
\end{pmatrix}\end{split}
$$

<Admonition title="Note" type="note">
In Qiskit’s convention, higher qubit indices are more significant (little endian convention). In many textbooks, controlled gates are presented with the assumption of more significant qubits as control, which in our case would be q\_1. Thus a textbook matrix for this gate will be:
Expand All @@ -45,16 +45,16 @@ python_api_name: qiskit.circuit.library.CRZGate
q_1: ────■────
```

$$
\begin{split}CRZ(\lambda)\ q_1, q_0 =
|0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes RZ(\lambda) =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & e^{-i\frac{\lambda}{2}} & 0 \\
0 & 0 & 0 & e^{i\frac{\lambda}{2}}
\end{pmatrix}\end{split}
$$
$$
\begin{split}CRZ(\lambda)\ q_1, q_0 =
|0\rangle\langle 0| \otimes I + |1\rangle\langle 1| \otimes RZ(\lambda) =
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & e^{-i\frac{\lambda}{2}} & 0 \\
0 & 0 & 0 & e^{i\frac{\lambda}{2}}
\end{pmatrix}\end{split}
$$
</Admonition>

<Admonition title="See also" type="note">
Expand Down
Loading

0 comments on commit 0bffa07

Please sign in to comment.