4

Tikzpicture

I have graph and small group. Trouble is. How create arrow from container AND from objects to objects?

3 objects 1,2,3 and container to object 0

  • Welcome to TeX.SX! What do you have done so far? Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Related: tex.stackexchange.com/a/110422/124842 – Bobyandbob Aug 5 '17 at 15:27
  • It will depend a bit on exactly how you made those boxes, but in general just \draw [->] (node A) -- (node B); – Torbjørn T. Aug 5 '17 at 15:30
  • I'm not have any computer with latex. Any answer will be ok – Marek Kaski Aug 5 '17 at 15:39
  • @MarekKaski, how then can help you latex code for image? – Zarko Aug 5 '17 at 15:40
  • ok, I send code for 10 h – Marek Kaski Aug 5 '17 at 16:01
5
  • image is out of context, so some parameters/options for image's elemets can be only guessed
  • you tagged question with luatex, is there some problem related to it?

enter image description here

  • arrows on above image are defined by join=by -Stealth and by \draw[-Stealth] (node i) to ["opis"] (node j)

mwe for above image:

\documentclass[ tikz, border=3mm]{standalone}
%---------------------------------------------------------------%
\usetikzlibrary{arrows.meta, chains, fit, positioning, quotes}

\begin{document}
    \begin{tikzpicture}[
node distance = 5mm and 7mm,
  start chain = A going above,
  base/.style = {rectangle, draw, rounded corners,
                 minimum width=24mm, minimum height=8mm},
 inbox/.style = {base, fill=blue!20, on chain, join=by -Stealth},
outbox/.style = {base, fill=red!20},
                    ]
\node [inbox]   {3};    % node name = A-1
\node [inbox]   {2};
\node [inbox]   {1};    %             A-3
\node (f)       [base, fit=(A-1) (A-3)] {};
\node (test)    [outbox, above=of f]    {Test};
%
\draw[-Stealth] (f) to ["opis" ']    (test);
    \end{tikzpicture}
\end{document}

short explanation of mwe code:

  • for all nodes is defined base style, which contain common node shapes features. it is latter used for define specific nodes in picture

  • for inner nodes (1, 2 and 3) is for placing used chains library. it put nodes in chain with distance between them determined by node distance = .... since chain is named (A) nodes are automatically named as A-1, A-2 and A-3

  • use of chains also enable macro join which simplified drawing connection lines between nodes in chain. style of connection can be determined locally (as is done in above mwe) or you can define external and this style also use for other lines in picture
  • around inner nodes is node "f" (as fit ..., but you can choose any name you liked), which fit them, i.e. it enclose all nodes between given coordinates. for this is used library fit which draw node's shape around specified nodes or coordinates. in your case this is obtained by fit=(A-1) (A-3) where (A-1) and (A-3) are names of the most outer nodes in the chain
  • for connection between f and start node is used arrows to which is add label "opis" (description? :) ). for it is used quotes library an+d syntax ["..."] which works only if for drawing line is used to or edge and not at --.
  • for more details about tikz please read "TikZ & PGF manual for version 3.0.1a. it is part of pgf installation in your computer. it is stored in "... \doc\generic\pgf\pgfmanual.pdf". manual is hige (over 1150 pages), but for start is sufucient to read tutorials and part III TikZ ist kein Zeichenprogramm
  • Thanks Zarko, thi is it. I have trouble with '\node (f) [base, fit=(A-1) (A-3)] {};' is any web page with example this library (fit) or other example chains,calc etc? – Marek Kaski Aug 6 '17 at 8:10
  • 1
    what trouble? it works :). for documentation search/google for pgfmanual.pdf, for example ctan.ijs.si/tex-archive/graphics/pgf/base/doc/pgfmanual.pdf. it is also part of any tikz installation. – Zarko Aug 6 '17 at 10:04
  • @MarekKaski, see added explanation. can you make a comment about other answer? is it maybe mwe for your question? and please clarify why you for your question select also tag "luatex" – Zarko Aug 6 '17 at 10:44
  • Thanks Zarko. opis = description (I'm from Poland ;) ) thanks for link i read documentation. I use simple graph, You answer is very good. I cant find latex therefore use lualatex. You code works fine. (I have trouble in my code ;) – Marek Kaski Aug 6 '17 at 17:57
0
\documentclass[twocolumn]{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{fit,arrows.meta}
\tikzset{%
 >={Latex[width=2mm,length=2mm]},
 base/.style = {rectangle, rounded corners, thick,
               minimum width=2em, minimum height=1em,
               node distance=6em, text centered, font=\sffamily},
}
\tikzset{jeden/.style={draw, fill=gray!15,node distance=6em}}
\tikzset{dwa/.style={ draw, rounded corners}}

\begin{document}
This is a text.
\tikzstyle{ramka} = [rectangle, draw, inner sep=0.5cm, dashed]
\begin{center}
\vskip 1mm
\begin{tikzpicture}[scale=.9, transform shape]
\node [jeden] (zero)  at  (0, 0)    {Test 0};
\node [dwa,right of=zero,name=one,node distance=9em] (one) {1};
\node [dwa,below of=one,node distance=4em] (two) {2};
\node [dwa,below of=two] (three) {3};
\node [dwa,below of=three,minimum width=7em] (four) {4};

\node [ramka, fit=(two) (four)] (container) {};

\draw [->] (one) -- (zero);
\draw [->] (container) -- node[text width=2cm,near end] {opis} (one);
\draw [->] (three) -- (two);
\draw [->] (four) -- (three);
\end{tikzpicture}
\end{center}
End off message. End of text.
\end{document}

And result

I add some modifications to show different distance. but base style not good

  • ow you know, that image had to be as is shown in your answer? it seems that your answer more question then an answer. is this missing code in @MarekKaski question? please, add some explanation. – Zarko Aug 5 '17 at 21:46
  • yes this is similar answer my question. – Marek Kaski Aug 6 '17 at 17:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.