如何在图片环境中使用 TikZ?

如何在图片环境中使用 TikZ?

现在在论文中我使用代码picture环境来绘制图片。但是这并不方便,因为有一些固定的矢量方向,对于特定的点来说很难定义(如果我想把它放在特定的坐标上)。

所以我想picturetikz图像交换。但picture我可以手动按坐标放置图像,并将\hangindent= \hangafter=其放在任何地方。这是我的示例例如。第一张图片需要更改

我怎样才能与 保持一致tikz我做嗎?

**注意:**我不想绘制图形/图像,然后将此图片文件添加到代码中。我希望我的图片使用一些包绘制在我的代码中,同样picture如此。

更新:下面图片的一些代码:

\hangindent=-5cm \hangafter=-7
\begin{picture}(0,0)(-90,30)
    {
    \thicklines  % parallelogram block
    \put(5,30){\line(1,0){15}}
    \put(20,30){\line(3,-5){15}}
    \put(35,5){\line(-1,0){15}}
    \put(20,5){\line(-3,5){15}}
    }
    \multiput(20,30)(2, 0){2}{\line(1,0){1}}
    \multiput(35,30)(0, -2.5){10}{\line(0,-1){1}}   % from (1) to the bottom
    \put(24,30){\line(-6,-3){18}}
    \put(17,16.5){\circle*{1}}
    \put(16,17.5){\scriptsize $d$}
    \put(24.7,22.2){\circle*{1}}
    \put(26,21){\scriptsize $(2)$}
    \put(24,30){\circle*{1}}    % dot point for (1)
    \put(25,31){\scriptsize $(1)$}
    \put(20,10){\Huge $S$}
\end{picture}

答案1

这显示了如何使用\raisebox\rlap重叠文本

\documentclass{article}
\usepackage{lipsum}

\begin{document}
\unitlength=0.1cm
\raisebox{-30\unitlength}[0pt][0pt]{\rlap{\hspace{80\unitlength}%
\begin{picture}(35,32)(0,0)
    {
    \thicklines  % parallelogram block
    \put(5,30){\line(1,0){15}}
    \put(20,30){\line(3,-5){15}}
    \put(35,5){\line(-1,0){15}}
    \put(20,5){\line(-3,5){15}}
    }
    \multiput(20,30)(2, 0){2}{\line(1,0){1}}
    \multiput(35,30)(0, -2.5){10}{\line(0,-1){1}}   % from (1) to the bottom
    \put(24,30){\line(-6,-3){18}}
    \put(17,16.5){\circle*{1}}
    \put(16,17.5){\scriptsize $d$}
    \put(24.7,22.2){\circle*{1}}
    \put(26,21){\scriptsize $(2)$}
    \put(24,30){\circle*{1}}    % dot point for (1)
    \put(25,31){\scriptsize $(1)$}
    \put(20,10){\Huge $S$}
\end{picture}}}
\hangindent=-5cm \hangafter=-7
\lipsum[1]
\end{document}

演示


这显示了如何使用 tikzpicture 的叠加和移位选项来定位图像。我添加了范围,以免混淆定位和缩放选项。

我应该补充一点,我不推荐这两种方法,尽管了解它们是有好处的。我喜欢使用 paracol。

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, arrows}
\usepackage{lipsum}

\begin{document}
\begin{tikzpicture}[overlay, xshift=3.5cm, yshift=-5cm]
  \begin{scope}[scale = 2,every node/.style={scale=1.25}, line cap=round,line join=round,>=triangle 45,x=0.8cm,y=0.8cm]
        \clip(1.8,-0.2) rectangle (5.2,3.3);
        \draw [thin] (3.,0.)-- (5.,0.);
        \draw [thin] (3.,0.)-- (2.,3.);
        \draw [thin] (5.,0.)-- (4.,3.);
        \draw [thin] (4.,3.)-- (2.,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (4.,3.)-- (4.6,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (4.6,3.)-- (4.401124147244972,1.7966275582650844);
        \draw [thin,dash pattern=on 1pt off 1pt] (3.2,1.8)-- (3.4,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (3.2,1.8)-- (4.6,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (3.2,1.8)-- (4.401124147244972,1.7966275582650844);
        \draw (3.218331276016167,0.7871588640135541) node[anchor=north west] {\LARGE\textit{S}};
        \draw (3.0146418611448365,1.7990353120840399) node[anchor=north west] {d};
        \begin{scriptsize}
            \draw [fill=black] (4.133333333333333,2.6) circle (1pt);
            \draw[color=black] (3.9476707937812523,2.669643295001828) node {(2)};
            \draw [fill=black] (4.6,3) circle (1pt);
            \draw[color=black] (4.6835809378325095,3.109875256175351) node {(1)};
            \draw [fill=black] (3.2,1.8) circle (1pt);
        \end{scriptsize}
    \end{scope}
\end{tikzpicture}
\hangindent=-5.5cm \hangafter=-13
\sloppy
\lipsum[1]
\end{document}

演示2

答案2

wrapfigure以类似的方式对齐。主要用于图像,支持tikz绘图和图形。

因此,做到这一点的一种方法是(尽管它的用途pgfplots,但我认为tikz情节的行为是类似的):

\begin{wrapfigure}{r}{5cm}
    \begin{tikzpicture}[scale = 2,every node/.style={scale=1.25}, line cap=round,line join=round,>=triangle 45,x=0.8cm,y=0.8cm]
        \clip(1.8,-0.2) rectangle (5.2,3.3);
        \draw [thin] (3.,0.)-- (5.,0.);
        \draw [thin] (3.,0.)-- (2.,3.);
        \draw [thin] (5.,0.)-- (4.,3.);
        \draw [thin] (4.,3.)-- (2.,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (4.,3.)-- (4.6,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (4.6,3.)-- (4.401124147244972,1.7966275582650844);
        \draw [thin,dash pattern=on 1pt off 1pt] (3.2,1.8)-- (3.4,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (3.2,1.8)-- (4.6,3.);
        \draw [thin,dash pattern=on 1pt off 1pt] (3.2,1.8)-- (4.401124147244972,1.7966275582650844);
        \draw (3.218331276016167,0.7871588640135541) node[anchor=north west] {\LARGE\textit{S}};
        \draw (3.0146418611448365,1.7990353120840399) node[anchor=north west] {d};
        \begin{scriptsize}
            \draw [fill=uuuuuu] (4.133333333333333,2.6) circle (1pt);
            \draw[color=uuuuuu] (3.9476707937812523,2.669643295001828) node {(2)};
            \draw [fill=uuuuuu] (4.6,3) circle (1pt);
            \draw[color=uuuuuu] (4.6835809378325095,3.109875256175351) node {(1)};
            \draw [fill=uuuuuu] (3.2,1.8) circle (1pt);
        \end{scriptsize}
    \end{tikzpicture}
\end{wrapfigure}

所以最终结果是这样的: 在此处输入图片描述

相关内容