-2

If possible I want to draw somthing close to a folder dir figure as a node object under tikzpicture:

enter image description here

Related: https://tex.stackexchange.com/a/174673/127048 here there is a tikz solution but I was not able to remove paper inside of the folder.

alper
  • 1,389

2 Answers2

2

Here is part of the solution, i.e. one way it could be done:

  • place a node
  • put as "text" a \tikz{ ...} call
  • see the red drawing in the screenshot below
    % ~~~ a simple way to put a drawing as a node ~~~~~
    \node [rotate=-30,red] at (0,-9) {\tikz{\pic [line width=7pt] at (0,0) {symb};}};

For simplicity I expanded my latest solution to an other question you posted: check the last \node statement at the end. As you can see:

  • you can pass most options to the \node [...]
  • however, at least the line width needs to be passed to the \pic

To define own nodes and shapes, see Ch. 106 in the manual. But I suppose, my approach is easier to digest and to apply.

result

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}

\begin{document} % ~~~ pictures ~~~~~~~~~ \tikzset{ symb/.pic={ \draw (1.5,3.25) -- (-2.65,3.25) -- (-2.65,-3.3) -- (2.85,-3.35) -- (2.85,1.85) -- cycle; \draw (-.45,.8) -- (-1.45,-.25) -- (-.55,-1.3); \draw ( .45,.8) -- ( 1.45,-.25) -- ( .55,-1.3); } } \tikzset{ pers/.pic={ \draw (1.5,3.25) -- (-2.65,3.25) -- (-2.65,-3.3) -- (2.85,-3.35) -- (2.85,1.85) -- cycle; \draw [fill=black,draw=white] (1.05,1.95) -- (-1.95,2) -- (-1.95,-2) -- (-0.95, -2) arc [start angle=180,end angle=90,radius=1cm] -- ++(0,0) arc [start angle=270,end angle=-90,radius=1cm] -- ++ (0,0) arc [start angle=90,end angle=0,radius=1cm] -- (2.05,-2) -- (2.05,1) -- cycle; } } % ~~~ demo ~~~~~~~~~~~~~~~~ \begin{tikzpicture}[line width=3pt] \pic at (0,0) {symb}; \pic at (6,0) {pers};

\pic at (12,-9) {pers};

% ~~~ a simple way to put a drawing as a node ~~~~~~~~~~~~
\node [rotate=-30,red] at (0,-9) {\tikz{\pic [line width=7pt] at (0,0) {symb};}};

\end{tikzpicture} \end{document}

MS-SPO
  • 11,519
2

Here's a way to do it. The basic concept is the same as described before, but now with a folder drawing:

  • lower left folder-in-a-node, line width=3pt
  • upper right, changed to \node [dashed] and smaller line width
  • just to demonstrate how to use it

result

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}

\begin{document} % ~~~ pictures ~~~~~~~~~ \tikzset{ folder/.pic={ % ~~~ back part ~~~~~~~~~~ \draw [fill=green!70!blue, rounded corners] (-1.43,-1.05) -- (-1.43,1.04) -- (-0.77,1.04) -- (-0.77,0.68) -- (0.94,0.68) -- (0.94,0.0) -- cycle; % ~~~ front part ~~~~~~~~~ \draw [fill=green!80!, rounded corners] (-1.43,-1.05) -- (-1.03,0.37) -- (1.29,.37) -- (0.90,-1.05) -- cycle; } }

% ~~~ demo ~~~~~~~~~~~~~~~~ \begin{tikzpicture}% [line width=3pt]
% ~~~ a simple way to put a drawing as a node ~~~~~~~~~~~~ \node at (0,-2) {\tikz{\pic [line width=3pt] at (0,0) {folder};}}; \node [dashed, rotate=20] at (4,1) {\tikz{\pic [line width=1pt] at (0,0) {folder};}}; \end{tikzpicture} \end{document}

P.S.: Some remarks on scaling effects. Tikz will have trouble to meet demands, when objects become too small. Example:

  • \pics called with line width=1pt
  • \pic sets rounded corners=5pt
  • upper folder uses only ,scale=.5]
  • lower one uses ,scale=.5,transform shape]

You can see artifacts, which are similar but not identical for both scaled pics. For the given coordinates limit seems to be around rounded corners=3pt to change between invisible and visible effect.

The reason is that Tikz tries to draw a rounded corner at the given coordinate with the given radius. Would the radius be smaller OR the coordinate difference in height be larger, it would have succeeded.

with artifacts

\documentclass[10pt,border=3mm,tikz]{standalone}
\usepackage{tikz}

\begin{document} % ~~~ pictures ~~~~~~~~~ \tikzset{ folder/.pic={ % ~~~ back part ~~~~~~~~~~ \draw [fill=green!70!blue, rounded corners=5pt] (-1.43,-1.05) -- (-1.43,1.04) -- (-0.77,1.04) -- (-0.77,0.68) -- (0.94,0.68) -- (0.94,0.0) -- cycle; % ~~~ front part ~~~~~~~~~ \draw [fill=green!80!, rounded corners] (-1.43,-1.05) -- (-1.03,0.37) -- (1.29,.37) -- (0.90,-1.05) -- cycle; } }

% ~~~ demo ~~~~~~~~~~~~~~~~ \begin{tikzpicture}% [line width=3pt]
% ~~~ a simple way to put a drawing as a node ~~~~~~~~~~~~ \node at (0,3) {\tikz{\pic [line width=1pt,scale=.5] at (0,0) {folder};}}; \node at (0,0) {\tikz{\pic [line width=1pt] at (0,0) {folder};}}; \node at (0,-3) {\tikz{\pic [line width=1pt,scale=.5,transform shape] at (0,0) {folder};}}; \node [dashed, rotate=20] at (4,1) {\tikz{\pic [line width=1pt] at (0,0) {folder};}}; \end{tikzpicture} \end{document}

MS-SPO
  • 11,519