答案1
调整cramped*
风格从我的另一个答案来看,它甚至更加紧密,并增加了supercramped
距离更小的样式。
(您不需要使用width
数学模式中测量元素大小的函数,您可以直接使用任何尺寸,甚至那些依赖于字体大小的尺寸(em 和 ex)。)
宏\mtikzcd
使得您可以&
在宏内部继续使用。amsmath
的\text
宏用于根据周围的数学风格提供某种程度的缩放。
代码
\documentclass{article}
\usepackage{amsmath, tikz-cd}
\tikzcdset{
/tikz/bullet/.style={shape=circle, fill, inner sep=+.13em, yshift=axis_height},
cramped*/.style={
arrows=overlay, /tikz/arrows={[scale=.6]}, line cap=round,
every matrix/.append style={
every outer matrix/.append style={inner sep=+0pt}},
every cell/.append style={inner sep=+0pt, outer sep=.5*width("$\;$")},
column sep/.evaluated=.75*width("${}\to{}$"),
row sep/.evaluated=.75*width("${}\to{}$")},
supercramped/.style={
cramped*, cells={outer sep=.25*width("$\;$")},
column sep/.evaluated=.5*width("${}\to{}$"),
row sep/.evaluated =.5*width("${}\to{}$")}}
\newcommand*\mtikzcd[1][]{%
\begingroup
\let\texbullet\bullet % store old definition
\def\bullet{|[bullet]|}% overwriting
\catcode`\&=\active\mmtikzcd{#1}}
\newcommand*\mmtikzcd[2]{%
\text{\begin{tikzcd}[cramped*,#1]#2\end{tikzcd}}\endgroup}
\begin{document}
\[
A^{\mtikzcd{\texbullet \rar[shift left] \rar[shift right] & \texbullet}}
\]
\[
B^{\mtikzcd{\bullet \rar[shift left] \rar[shift right] & \bullet \rar & A}}
\]
\[
C^{\mtikzcd[supercramped]{ & \bullet \dar \\ \bullet \rar & \bullet}}
\]
\end{document}
输出
答案2
像这样:
\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}
\tikzset{dot/.style = {circle, fill, inner sep=1pt},
arr/.style = {-{Straight Barb[scale=0.8]}, shorten > = 1pt, shorten <=1pt}
}
\begin{document}
\lipsum[1][1-1] Image
\tikz[node distance = 3mm and 3mm, baseline=0.9ex]{
\node[dot] (a) {};
\node[dot,right=of a] (b) {};
\node[dot,above=of b] (c){};
\draw[arr] (a) -- (b);
\draw[arr] (c) -- (b);} shows \dots
\lipsum[1][2-3]
\end{document}