现在,如果我仅创建一个包含所有内容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)$)}