Tikz 圖片內嵌

Tikz 圖片內嵌

有沒有辦法將 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}

上面程式碼片段的輸出

答案3

這裡有一個關於如何放置內聯並且 tikz 程式碼距離文字不夠高的建議。

\raisebox{-2pt}{\tikz{\draw[line width=1pt, >->] (0, 0) arc (-180:0:8pt);}}

給我的輸出如下,我想這相當不錯。

在此輸入影像描述

相關內容