Quantikz 打破 tikz 矩阵/tikz-cd 中的间距

Quantikz 打破 tikz 矩阵/tikz-cd 中的间距

现在,如果我仅创建一个包含所有内容inner sep并将outer sep其设置为 0 的简单图表,则仍然没有间距:

在此处输入图片描述

现在,如果我还加载 quantikz,间距就会很糟糕(quantikz 也会破坏基线,但这很容易修复):

在此处输入图片描述

有什么办法可以修复它吗?

\documentclass[a4paper,12pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{cd}
%% Really Breaks spacing:
\usetikzlibrary{quantikz}
\begin{document}
\setlength{\fboxsep}{0pt}
% Even without quantikz, the spacing is not null. With quantikz, it gets even worse.
Hello \fbox{\begin{tikzcd}[ampersand replacement=\&,inner sep=0pt,outer sep=0pt,column sep=0pt,row sep=0pt,baseline={([yshift=-axis_height]current bounding box.center)},]|[draw,inner sep=0pt, outer sep=0pt]|A\end{tikzcd}}.

\end{document}

答案1

好的,我终于找到问题了。问题是quantikz修补了一个tikzcd函数(和另一个函数):

\patchcmd\tikzcd@{\tikzpicture}{\def\toslice{0}\def\vert{0}
 \begin{tikzpicture}}{}{}

并且它忘记放一个%,也就是说它应该是:

\patchcmd\tikzcd@{\tikzpicture}{\def\toslice{0}\def\vert{0}%
 \begin{tikzpicture}}{}{}

为了暂时使用原始功能,我这样做了:

\documentclass[a4paper,12pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{cd}
\makeatletter
\let\tikzcd@@original\tikzcd@%
\let\endtikzcd@original\endtikzcd%
\makeatother
%% Really Breaks spacing:
\usetikzlibrary{quantikz}
\begin{document}
\setlength{\fboxsep}{0pt}
% Even without quantikz, the spacing is not null. With quantikz, it gets even worse.
{
  \makeatletter
  \let\tikzcd@\tikzcd@@original
  \let\endtikzcd\endtikzcd@original
  \makeatother
  Hello \fbox{\begin{tikzcd}[ampersand replacement=\&,inner sep=0pt,outer sep=0pt,column sep=0pt,row sep=0pt,baseline={([yshift=-axis_height]current bounding box.center)},]|[draw,inner sep=0pt, outer sep=0pt]|A\end{tikzcd}}.
}

\end{document}

关于底线,我认为它来自


/tikz/baseline={([yshift=-\MathAxis]\noexpand\tikzcdmatrixname-\wholepart-1.base)}

/tikz/baseline={([yshift=-\MathAxis]$(\noexpand\tikzcdmatrixname-\wholepart-1.base)!\fractionalpart!(\noexpand\tikzcdmatrixname-\neighbour-1.base)$)}

相关内容