有没有办法将 tikzpicture 代码内联?以下是我想要实际实现的:
凸函数表示为“凸度的 tikz 代码“
有人告诉我这是可能的。此外,在 tikz-pgf 教程中,我看到了许多内联的 tikz 代码。例如,在缩放部分,作者将一个旋转椭圆放在内联中(即文本旁边)
如何实现这一点?
答案1
用作tikzpicture
环境或\tikz
内联宏。
但是线条拉伸的问题还是比较明显的!
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
A stupid text followed by \begin{tikzpicture}\draw[fill=red,line width=1pt] circle(1ex);\end{tikzpicture}
A stupid text followed by \tikz{\draw[fill=red,line width=1pt] circle(1ex);}
A stupid text followed by another stupid text followed
A stupid text followed by some dots \tikz{%
\foreach \x /\cola in {1/blue,2/yellow,3/red,4/green,5/orange} {%
\shade[ball color=\cola] (\x,0) circle(0.5ex*\x);
}%
}
\end{document}
答案2
来自我的真实文档的另一个例子:
\documentclass{article}
\usepackage{tikz}
\newcommand{\ground}{%
\begin{tikzpicture}[scale=0.5, baseline=-3mm, thick]
\draw (0,0) -- +(0mm,-4.0mm) {
[yshift=-4mm]
+(-2mm,0mm) -- +(2mm,0mm)
+(-1mm,-1mm) -- +(1mm,-1mm)
+(-0.3mm,-2mm) -- +(0.3mm,-2mm)
};
\end{tikzpicture}%
}
\begin{document}
We have a text here, and then I refer to the ground (\ground) connection point in the instrument. Clearly, the \ground{} symbol will change the spacing...
you can play with the \texttt{scale} and \texttt{baseline=-3mm} parameters in the definition\dots
\end{document}