17

I would like to draw something similar to this (see below) with Tikz. Except for the lines and the dog-eared thing. That is, I want to draw three nodes with a layer effect...

a bunch of documents

What I've tried so far :

\documentclass[a4paper,openright,twoside,11pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[font=\sffamily]
\tikzstyle{doc}=[%
minimum height=4em,
minimum width=3em,
draw
]

   \node[] (smthng) {};

   \node[doc] (doc) [below = of smthng] {docs};
   \node[doc] (doc2) [below = of smthng,yshift=4pt,xshift=4pt] {};
   \node[doc] (doc3) [below = of smthng,yshift=-4pt,xshift=-4pt] {};
\end{tikzpicture}
\caption{My docs.}
\end{figure}

\end{document}

Which produces :

enter image description here

Now I want node doc2 to be partially hidden by doc ; and doc partially hidden by doc3. How can I achieve that?

[EDIT] Actually the label docs should be on doc3...

  • Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. – LaRiFaRi Jul 7 '15 at 9:06
  • @LaRiFaRi I see your point, however I don't see what would be a good MWE here... – Pierre Jul 7 '15 at 9:10
  • 1
    What @LaRiFaRi is saying is that it would be helpful if you composed a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem and shows what you have tried. For instance, can you produce ONE of the above "document icons" to your liking? If not, show how far you were able to get towards your goal. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – Peter Grill Jul 7 '15 at 9:18
  • @PeterGrill done :) – Pierre Jul 7 '15 at 9:39
  • 1
    Possible duplicate of: tex.stackexchange.com/a/94544/1952, tex.stackexchange.com/a/159326/1952 – Ignasi Jul 7 '15 at 10:19
17

I've seen this figure in TeX.SX, but while I try to find it, here you have a possible solution:

\documentclass[a4paper,openright,twoside,11pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[font=\sffamily]
\tikzstyle{doc}=[%
minimum height=4em,
minimum width=3em,
draw, fill=white
]
   \node[doc] (doc) {};
   \node[doc, below left = 4pt and 4pt of doc.north east] (doc2) {};
   \node[doc, below left = 4pt and 4pt of doc2.north east] (doc3) {docs};
\end{tikzpicture}
\caption{My docs.}
\end{figure}

\end{document}

Update: Even easier with a double copy shadow

double copy shadow style from shadows library can do it with less code:

\documentclass[a4paper,openright,twoside,11pt]{memoir}
\usepackage{tikz}
\usetikzlibrary{positioning, shadows}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[font=\sffamily,
    doc/.style={draw, minimum height=4em, minimum width=3em, 
                fill=white, 
                double copy shadow={shadow xshift=4pt, 
                             shadow yshift=4pt, fill=white, draw}},
]
   \node[doc] (doc) {doc};
\end{tikzpicture}
\caption{My docs.}
\end{figure}

enter image description here

  • fill=white ! thanx it helped :) – Pierre Jul 7 '15 at 9:58
  • @Pierre: It's easier with double copy shadow. Answer updated – Ignasi Jul 7 '15 at 10:06
18

Here's a bit of an overkill solution. :D

Ouput

figure 1

Code

\documentclass{article}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{calc,arrows.meta,positioning}

\tikzset{
    arr/.style={{Round Cap[]}-{Round Cap[]}, line width=1.5mm, shorten >=3.5mm, shorten <=3.5mm}
}

\newcommand{\picon}[1][1]{
\scalebox{#1}{%
\tikz{
    \begin{scope}[shift={(1,1)}]
    \node[draw, fill=white, line width=2mm, minimum height=2.5cm, minimum width=1.8cm] (o) at (0,0) {};
    \draw[white, fill=white] ($(o.north east)+(-6mm,0)$) --++ (6mm,0) --++ (0,-6mm) -- cycle;
    \fill[black] ($(o.north east)+(0,-6mm)$) --++ (0,-1mm) --++ (-7mm,0) --++ (0,7mm) --++ (1mm,0) -- cycle;
    \end{scope}
    \begin{scope}[shift={(.5,.5)}]
    \node[draw, fill=white, line width=2mm, minimum height=2.5cm, minimum width=1.8cm] (p) at (0,0) {};
    \draw[white, fill=white] ($(p.north east)+(-6mm,0)$) --++ (6mm,0) --++ (0,-6mm) -- cycle;
    \fill[black] ($(p.north east)+(0,-6mm)$) --++ (0,-1mm) --++ (-7mm,0) --++ (0,7mm) --++ (1mm,0) -- cycle;
    \node[anchor=south west, fill=white, minimum width=1cm, minimum height=1.5mm, outer sep=0, inner sep=0] at (p.north west) {};
    \node[anchor=south west, fill=white, minimum width=1.5mm, minimum height=1cm, outer sep=0, inner sep=0] at (p.south east) {};
    \end{scope}
    \node[draw, fill=white, line width=2mm, minimum height=2.5cm, minimum width=1.8cm, inner sep=0] (n) at (0,0) {};
    \draw[white, fill=white] ($(n.north east)+(-6mm,0)$) --++ (6mm,0) --++ (0,-6mm) -- cycle;
    \fill[black] ($(n.north east)+(0,-6mm)$) --++ (0,-1mm) --++ (-7mm,0) --++ (0,7mm) --++ (1mm,0) -- cycle;
    \node[anchor=south west, fill=white, minimum width=1cm, minimum height=1.5mm, outer sep=0, inner sep=0] at (n.north west) {};
    \node[anchor=south west, fill=white, minimum width=1.5mm, minimum height=1cm, outer sep=0, inner sep=0] at (n.south east) {};
    \foreach \n in {.32,.44,.56,.68,.8}{
    \draw[arr] ($(n.north west)!\n!(n.south west)$) -- ($(n.north east)!\n!(n.south east)$);}
    \node[anchor=south west, minimum size=2.4mm,fill=black, outer sep=0, inner sep=0] (m) at ($(o.north east)+(-7mm,-7mm)$) {};
    \node[anchor=south west, minimum size=2.4mm,fill=black, outer sep=0, inner sep=0] (m) at ($(p.north east)+(-7mm,-7mm)$) {};
    }}
}

\begin{document}
\lipsum*[1]

\begin{figure}[!h]
\centering
\picon
\caption{Some docs}
\end{figure}

\lipsum*[2]

\begin{figure}[!h]
\centering
\picon[.2]
\caption{Smaller docs}
\end{figure}
\end{document}
8

I needed to do the same kind of thing, here's my solution

\documentclass{standalone} 
\usepackage{tikz}
\usetikzlibrary{positioning,calc}
\begin{document} 
   \begin{tikzpicture}
     \def\corner{0.15in};
     \def\cornerradius{0.02in};
     \def\lwidth{0.02in};
     \def\h{1.1in};
     \def\w{0.85in};
     \def\nline{10};
     \def\iconmargin{0.1in};
     \def\topmargin{0.3in};
     \foreach[count=\i] \filename in {bar.c,bar.h,foo.c,foo.h}
     {
     \coordinate (nw) at ($(-0.05in*\i,-0.15in*\i)$);
     \coordinate (ne0) at ($(nw) + (\w, 0)$);
     \coordinate (ne1) at ($(ne0) - (\corner, 0)$);
     \coordinate (ne2) at ($(ne0) - (0, \corner)$);
     \coordinate (se) at ($(ne0) + (0, -\h)$); 
     \filldraw [-, line width = \lwidth, fill=white] (nw) -- (ne1) -- (ne2)
      [rounded corners=\cornerradius]--(se) -- (nw|-se) -- cycle;
     \draw [-, line width = \lwidth] (ne1) [rounded corners=\cornerradius]-- (ne1|-ne2) -- (ne2);
     \node [anchor=north west] at (nw) {\scriptsize \tt \filename};
     \foreach \k in {1,...,\nline}
     {
       \draw [-, line width = \lwidth, line cap=round] 
         ($(nw|-se) + (\iconmargin,\iconmargin) + (0,{(\k-1)/(\nline-1)*(\h - \iconmargin - \topmargin)})$)
           -- ++ ($(\w,0) - 2*(\iconmargin,0)$);
     }
     }
   \end{tikzpicture}
\end{document}

enter image description here

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.