我如何用文本或文本框替换字母。请考虑以下示例。您可能会在输出中注意到,文本不太好。有办法纠正吗?
\documentclass{article}
\usepackage{tikz-cd}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,calc,shapes.misc,decorations.markings}
\tikzset{degil/.style={
decoration={markings,
mark= at position 0.5 with {
\node[transform shape] (tempnode) {$\backslash$};
%\draw[thick] (tempnode.north east) -- (tempnode.south west);
}
},
postaction={decorate}
}
}
\begin{document}
\begin{tikzcd}[arrows=Rightarrow]
& B \arrow[degil,shift left=1.5ex]{dr}{} & \\
Stochastic Independence \arrow{ur} & & C \arrow [shift left=.5ex]{ul} \\
& D \arrow{ur} &
\end{tikzcd}
\end{document}
答案1
这里有两种可能性,使用mathtools
和stackengine
:
\documentclass{article}
\usepackage{mathtools}
\usepackage{stackengine}
\setstackEOL{\\}
\usepackage{tikz-cd}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,calc,shapes.misc,decorations.markings}
\tikzset{degil/.style={
decoration={markings,
mark= at position 0.5 with {
\node[transform shape] (tempnode) {$\backslash$};
%\draw[thick] (tempnode.north east) -- (tempnode.south west);
}
},
postaction={decorate}
}
}
\begin{document}
\begin{tikzcd}[arrows=Rightarrow]
& B \arrow[degil,shift left=1.5ex]{dr}{} & \\
\fbox{\Centerstack[l]{Stochastic\\Independence}}\arrow{ur} & & C \arrow [shift left=.5ex]{ul} \\
& D \arrow{ur} &
\end{tikzcd}
\vskip 1cm
\begin{tikzcd}[arrows=Rightarrow]
& B \arrow[degil,shift left=1.5ex]{dr}{} & \\
\Centerstack[l]{Stoch\rlap{astic}\\\rlap{Independence}}\arrow{ur} & & C \arrow [shift left=.5ex]{ul} \\
& D \arrow{ur} &
\end{tikzcd}
\end{document}
答案2
不需要其他包,除非amsmath
在文档中使用数学时建议使用。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri,calc,shapes.misc,decorations.markings}
\tikzset{degil/.style={
decoration={markings,
mark= at position 0.5 with {
\node[transform shape] (tempnode) {$\backslash$};
%\draw[thick] (tempnode.north east) -- (tempnode.south west);
}
},
postaction={decorate}
}
}
\begin{document}
\begin{tikzcd}[arrows=Rightarrow]
& B \arrow[degil,shift left=1.5ex]{dr}{} & \\
\text{Stochastic Independence} \arrow{ur} & & C \arrow [shift left=.5ex]{ul} \\
& D \arrow{ur} &
\end{tikzcd}
\begin{tikzcd}[arrows=Rightarrow]
& B \arrow[degil,shift left=1.5ex]{dr}{} & \\
\begin{tabular}{@{}c@{}}Stochastic\\ Independence\end{tabular} \arrow{ur}
& & C \arrow [shift left=.5ex]{ul} \\
& D \arrow{ur} &
\end{tikzcd}
\begin{tikzcd}[arrows=Rightarrow]
& B \arrow[degil,shift left=1.5ex]{dr}{} & \\
\fbox{\begin{tabular}{@{}c@{}}Stochastic\\ Independence\end{tabular}} \arrow{ur}
& & C \arrow [shift left=.5ex]{ul} \\
& D \arrow{ur} &
\end{tikzcd}
\end{document}