3

This code

\documentclass{article}
\usepackage{tikz-cd}
% \usetikzlibrary{quantikz2}
\begin{document}
\begin{tikzcd}[ampersand replacement=\&]
    A \arrow[rrrr, ""] \& \& \& \& B \arrow[rd, ""] \\
    \& \& \& \& \& C \\
    D \arrow[rrrr, ""] \& \& \& \& E \arrow[ru]
\end{tikzcd}
\end{document}

produces this:

enter image description here

This code

\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{quantikz2}
\begin{document}
\begin{tikzcd}[ampersand replacement=\&]
    A \arrow[rrrr, ""] \& \& \& \& B \arrow[rd, ""] \\
    \& \& \& \& \& C \\
    D \arrow[rrrr, ""] \& \& \& \& E \arrow[ru]
\end{tikzcd}
\end{document}

produces this:

enter image description here

How do I get the first result if I need to use quantikz in my document? Loading quantikz locally for each diagram seems painful.

mavzolej
  • 556
  • 1
    I think you mean "altering" not "alternating" in the title. Also, quantikz not quantikz2. – Sandy G Mar 21 '24 at 02:43
  • It's quantikz2 actually. – mavzolej Mar 21 '24 at 03:24
  • Not sure, what you are after. However, this approach lets you combine anything, because you avoid such conflicts, while preserving vector graphics: https://tex.stackexchange.com/a/713595/245790. – MS-SPO Mar 21 '24 at 04:21
  • 1
    \usetikclibrary{quantikz2} uses xparse and etoolbox to modify TikZ. making it incompatible with any other use of TikZ, Tikzcd should't cause any problems. – John Kormylo Mar 21 '24 at 17:55

1 Answers1

1
  1. To have both, separate in space (i.e. in files here).
  2. Join later.

1) create and compile individual files

Kindly recognize the different documentclass.

t-tex:

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz-cd}

\begin{document} \begin{tikzcd}[ampersand replacement=&] A \arrow[rrrr, ""] & & & & B \arrow[rd, ""] \ & & & & & C \ D \arrow[rrrr, ""] & & & & E \arrow[ru] \end{tikzcd} \end{document}

q.tex:

\documentclass[10pt,border=3mm,tikz]{standalone}
\usetikzlibrary{quantikz2}

\begin{document} \begin{quantikz}[ampersand replacement=&] A \arrow[rrrr, ""] & & & & B \arrow[rd, ""] \ & & & & & C \ D \arrow[rrrr, ""] & & & & E \arrow[ru] \end{quantikz} \end{document}

2) Your main document

main.tex:

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}

\begin{document} \includegraphics[width=\textwidth]{t} \includegraphics[width=.5\textwidth]{q} \end{document}

result

MS-SPO
  • 11,519