2

I am trying to draw the following image using tikz libray. What I did so far is this:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shadows,fadings}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}

\begin{document}
    \begin{figure}
    \centering
        \begin{tikzpicture}[
            myrectangle/.style={rectangle, draw, minimum width=160, minimum height=40, ultra thick, rounded corners=0, red, text=black}
        ]

            \node[myrectangle,drop shadow={top color=red,
              bottom color=white,
              shadow xshift=1em,
              shadow yshift=-4em,
              rounded corners },] (a) at (0,0)     {\Large Some Long Text Goes here};
            \node[myrectangle, right=0 of a, xshift=3cm] (b) {\Large B};
            \node[myrectangle] (a) at (0,-5)     {\Large text};
            \node[myrectangle, right=0 of a, xshift=3cm] (b) {\Large B};
        \end{tikzpicture}
    \end{figure}
\end{document}

Which has this result: enter image description here

What I want is the following: enter image description here

  1. The padding on left of this figure is more than the right. I want the left padding to be the same as the right padding
  2. The text inside the green circle "Some long text goes here" should be in two line. For example "Some long text" in one line and "goes here" in new line
  3. I need to have a little shadow below and to the right side of each rectangle. The shadow in my figure is way too much what i need is about a 1mm thick shadow. For example the amount of shadow highlighted using silver line.
  4. And the rectangles should have arrows with labels as shown (blue color arrows)
  • 1
    the padding on the left is normal in the article class which is in American format with a very large margin on the left. Use the geometry package to modify the margins with for example \usepackage[margin=1cm]{geometry} – AndréC Oct 27 '18 at 6:15
2

Here is a proposal.

  1. I added the geometry package. It shows the frame to show that the picture is centered, but you may remove showframe of course.
  2. To allow the text to break into more than one lines, I added align=center to the options.
  3. Then I added the shadow to the definition of myrectangle, and made its dimension smaller.
  4. The arrows with labels are added using edges together with quotes.

Result:

\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{tikz}
\usetikzlibrary{shadows,fadings}
\usetikzlibrary{positioning,quotes}

\begin{document}
    \begin{figure}
    \centering
        \begin{tikzpicture}[font=\Large,
            myrectangle/.style={rectangle, draw, minimum width=160, minimum height=40, ultra thick, rounded corners=0, red, 
            text=black,align=center,fill=white,  %<- added align=center and fill=white
            drop shadow={top color=red,
              bottom color=white,
              shadow xshift=1mm, %<- changed the dimension
              shadow yshift=-1mm,
              rounded corners }}  %<- moved shadow here
        ]

            \node[myrectangle] (a) at (0,0)     {Some Long Text\\ Goes here};
            \node[myrectangle, right=3cm of a] (b) { B};
            \node[myrectangle] (c) at (0,-5)     {text};
            \node[myrectangle, right=3cm of c] (d) {B};
            \draw (a) edge[-latex,"y"] (b)
            (b) edge[-latex,"x"] (d)
            (d) edge[-latex,"z"] (c)
            (c) edge[-latex,"b"] (a);
        \end{tikzpicture}
    \end{figure}
\end{document}

enter image description here

  • God bless you. Its perfect – Saad Oct 27 '18 at 6:34
  • One question. Can I increase the width of the directed arrows? – Saad Oct 27 '18 at 6:37
  • @Saad Just do \draw[thick] (a) edge[-latex,"y"] (b) (b) edge[-latex,"x"] (d) (d) edge[-latex,"z"] (c) (c) edge[-latex,"b"] (a);, say. – user121799 Oct 27 '18 at 12:31

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.