LaTeXStrings

Here we define methods which converts QuantumCircuit object into quantikz LaTeX source code. When you want Quantikz Picture directly, refer quantikz page.

Documents

GroverAlgorithm.controlled_gate_targetMethod
controlled_gate_target(gate_type::Symbol) -> String

Given a gate type symbol, return the appropriate LaTeX string for the target part of a controlled gate in a quantum circuit diagram.

  • For :X, :CNOT, :CX, it returns \targ{}.
  • For :Z, :CZ, it returns \ctrl{0}.
  • For :Y, :CY, it returns \gate{Y}.
  • For :CPHASE, :Cphase, it returns \ctrl{0}.
  • For other gate types, it returns \gate{<LaTeX representation of the gate>} using the gate_to_latex function.
source
GroverAlgorithm.format_paramMethod
format_param(θ::Real) -> String

Convert a rotation angle θ (in radians) to a LaTeX-friendly string representation.

  • If θ is a multiple of π, it returns a string like "π", "2π", "-π", etc.
  • If θ is a rational multiple of π (e.g., π/2, π/4), it returns a string like "π/2", "π/4", etc.
  • For other values, it returns a decimal representation rounded to 3 decimal places.
source
GroverAlgorithm.gate_to_latexMethod
gate_to_latex(gate_type::Symbol, params::AbstractVector{<:Real}) -> String

Convert a parameterized gate type symbol and its parameters to a LaTeX string representation for visualization in quantum circuit diagrams. Supported parameterized gate types include:

  • Single-qubit rotation gates: :Rx, :Ry, :Rz, :Rn
  • Controlled rotation gates: :CRx, :CRy, :CRz, :CRn
  • Two-qubit rotation gates: :Rxx, :Ryy, :Rzz
  • Phase gates: :Phase, :P, :S

If the gate type is not recognized, it returns the string representation of the symbol along with its parameters in parentheses.

source
GroverAlgorithm.gate_to_latexMethod
gate_to_latex(gate_type::Symbol) -> String

Convert a gate type symbol to its corresponding LaTeX string representation for visualization in quantum circuit diagrams. Supported gate types include:

  • Single-qubit gates: :X, :Y, :Z, :H, :T, :S, :Phase, :P, :Proj0, :Proj1, etc.
  • Two-qubit gates: :CNOT, :CY, :CZ, :CPHASE, :SWAP, :iSWAP, etc.
  • Three-qubit gates: :Toffoli, :Fredkin, etc.
  • Four-qubit gates: :CCCNOT, etc.

If the gate type is not recognized, it returns the string representation of the symbol itself.

source