1

Now in paper for code I'm using picture environment for picture drawing. However it's not convenient since there's some fixed vector directions, which are hard to define for specific dot (if I want to put it on specific coordinate).

So I want to exchange picture with tikz images. But with picture I could manually put image by coordinate and with \hangindent= \hangafter= to put it anywhere. Here is my example Example. First picture needs to be changed :

How can I do such good aligning with tikz? And can I do it?

**NOTE: ** I don't want to draw figures/images and then add this picture file to code. I want my pictures drawing with some package inside my code, as picture does.

UPD: some code for the picture below:

\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}
11
  • I would utilize Mathcha :-) mathcha.io/editor
    – Sebastiano
    May 2, 2021 at 22:28
  • 1
    @Sebastiano, not sure if I understand you or you understand me correct. I don't want to use third party files
    – taciturno
    May 2, 2021 at 22:31
  • 1
    I misunderstood your question. I thought you wanted to draw the images. Sorry.
    – Sebastiano
    May 2, 2021 at 22:35
  • 1
    @Sebastiano, ok maybe it was my fault since I didn't mention it in post. I'll correct it
    – taciturno
    May 2, 2021 at 22:36
  • 2
    you could use tikz but also look at pict2e package which extends picture to allow vectors specified by coordinate May 2, 2021 at 23:22

2 Answers 2

3

This shows how to use \raisebox and \rlap to overlap text

\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}

demo


This shows how to use the overlay and shift options of tikzpicture to position the image. I added the scope so as to not confuse the positioning and scaling options.

I should add that I don't recommend either of these approaches, although it is good to know about them. I like to use 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}

demo2

2

wrapfigure aligns in a similar way. Mainly for images, it supports tikz plots and graphs.

So the one way to do this is (though it's uses pgfplots, but I think behaviour for tikz plots is similar):

\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}

So in the end it turns out to be this: enter image description here

2
  • I was more curious about how you used picture than how to use wrapfig and tikz. May 3, 2021 at 18:59
  • @JohnKormylo, ok, I'll insert some code in a question now
    – taciturno
    May 3, 2021 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .