3

Those are the three flowcharts I want to draw, and there are some problems:

  1. How to add the Dashed Box and Cross in the third picture.

  2. I don't know how to add the rectangle Bond worth P in the first picture.

enter image description here

\documentclass[UTF8]{ctexart}

\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{shapes.geometric, arrows,calc,decorations.markings}
\tikzset{
    process/.style={
        text width=2.5cm, draw,
        minimum height=1.6cm,
        text centered,
        },
    process1/.style={
        text width=2.5cm, draw,
        minimum height=0.8cm,
        text centered,
        },
    description/.style={
        text centered,
        text width=10cm,
    },
    myarrow/.style={
        postaction={
            decorate, decoration={
                markings,mark=at position #1 with {\arrow{Stealth};
                }
            }
        }
    },
}
\usepackage{setspace}
\usepackage{etoolbox}
\AtBeginEnvironment{tikzpicture}{\singlespacing}

\begin{document}

\pagestyle{empty}
\begin{center}
    \begin{tikzpicture}
    \node[process] (p1) {Default\\ protection\\ buyer};
    \node[process, right=10em of p1]  (p2) {Default\\ protection\\ seller};

    \draw[-Stealth, line width=1pt] ([yshift=-8ex, xshift=8ex]p2.west) -- node[description, above] {100} ([yshift=-8ex, xshift=-8ex]p1.east);
    \draw [-Stealth, line width=1pt]([yshift= 8ex,xshift=0.5cm]$(p1)$) --node[midway] (Rect){}([yshift=8ex,xshift=-.5cm]$(p2)$);
    \draw[fill=white] ($(Rect)+(-1.5,-0.7)$)rectangle($(Rect)+(1.5,0.7)$) node[midway] (Text){};
    \node at (Text) {\begin{minipage}{3cm}\centering
             Bond\\ worth P
          \end{minipage}};
    \end{tikzpicture}
\end{center}

\begin{center}
    \begin{tikzpicture}
    \node[process] (p1) {Asset Swap\\ Seller};
    \node[process, right=8em of p1]  (p2) {Asset Swap\\ Buyer};
    \node[process1, right=4em of p2]  (p3) {Bond};

    \draw[-Stealth] ([yshift=2ex]p1.east) -- node[description, above] {C} ([yshift=2ex]p2.west);
    \draw[-Stealth] ([yshift=-2ex]p2.west) -- node[description, below] {LIBOR + S} ([yshift=-2ex]p1.east);
    \draw[-Stealth] (p3.west) -- node[description, below] {C} (p2.east);
    \draw[dashed] ($(p1)+(-1.8,-1)$)rectangle($(p2)+(1.8,1)$);
    \draw[ultra thick] ($(p3)+(-1.7,-0.8)$)--($(p3)+(1.7,0.8)$);
    \draw[ultra thick] ($(p3)+(-1.7,0.8)$)--($(p3)+(1.7,-0.8)$);

    \end{tikzpicture}
\end{center}

\end{document}  
5

like this:

enter image description here

edit: in comparison to your code i made the following changes, which make code more clear, easy to understand and concise:

  • to tikzlibrary are added libraries fit, positioning, quotes, shapes.misc and removed not used in this images
  • used is decent tikz syntax
  • used are document class article in combination with package geometry instead of ctexart. this doesn't influence on image design and usability.
  • defined is new, universal style for all boxes in flowchart which enable automatic text breaking into more lines, has shadow around node and has option for determining node width (by this all used mini pages become superfluous)
  • for dashed frame around " and "Asset Swap Buyer" i define new node style fbox (as frame box), which is positioned by use of tikz library fit
  • for cross out a node is defined new box style using library shapes.misc
  • for nodes positioning are used library positioning, for lines between nodes are determined auxiliary coordinates (c, c1 and c2), which simplify drawing nodes.
  • for labels on lines is used library quotes
  • i didnt bother with line spacing in your document. your solution will work with this code without any problem

\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, fit, positioning, quotes,
                shadows, shapes.geometric, shapes.misc}

\tikzset{FlowChart/.style =
{
  box/.style = {rectangle, draw, fill=white,
               text width=##1, minimum height=8mm, align=center,
               inner sep=2mm, outer sep=0mm,
               drop shadow={shadow xshift=2mm, shadow yshift=-2mm}
               },
box/.default = 22mm,
 cbox/.style = {cross out=1m, draw, very thick,
                inner sep=3mm, node contents={}},
 fbox/.style = {rectangle, draw, densely dashed, inner sep=4mm},
   LA/.style = {semithick, -Triangle}
}
        }

\begin{document}
\pagestyle{empty}
some text
\begin{center}
    \begin{tikzpicture}[FlowChart,
node distance = 0mm and 8mm
                        ]
\node (p1) [box] {Asset Swap Seller};
\node (p2) [box=32mm, above right=of p1] {Bond\\ worth P};
\node (p3) [box, below right=of p2] {Asset Swap Buyer};
%
\draw [LA]  (p1 |- p2) -- (p2)
            (p2) -- (p2 -| p3);
%
\coordinate[below=4mm of p1.south] (c);
\draw [LA]  (p3.south |- c) to ["100"]  (c);
% fake node,
\node[right=38mm of p3.east] {};
    \end{tikzpicture}
\end{center}
some text
\begin{center}
    \begin{tikzpicture}[FlowChart,
node distance = 0mm and 8mm
                        ]
\node (p1) [box] {Asset Swap Seller};
\node (p2) [box, right=48mm of p1] {Asset Swap Buyer};
\node (p3) [box, right=16mm of p2] {Bond};
%
\node (p4) [fbox, fit=(p1) (p2)]  {};
%
\coordinate[above=2mm of p1.east] (c1);
\coordinate[below=2mm of p1.east] (c2);
\draw [LA]  (c1 -| p2.west) to ["C" '] (c1);
\draw [LA]  (c2) to ["LIBOR + C" '] (c2 -| p2.west);
%
\draw [LA,very thick]  (p3) to ["C" ']  (p2);
    \end{tikzpicture}
\end{center}
some text
\begin{center}
    \begin{tikzpicture}[FlowChart,
node distance = 0mm and 8mm
                        ]
\node (p1) [box] {Asset Swap Seller};
\node (p2) [box, right=48mm of p1] {Asset Swap Buyer};
\node (p3) [box, right=16mm of p2] {Bond};
%
\node (p4) [fbox, fit=(p1) (p2)]  {};
\node      [cbox, fit=(p3)];
%
\coordinate[above=2mm of p1.east] (c1);
\coordinate[below=2mm of p1.east] (c2);
\draw [LA]  (c1 -| p2.west) to ["C" '] (c1);
\draw [LA]  (c2) to ["LIBOR + C" '] (c2 -| p2.west);
%
\draw [LA,very thick]  (p3) to ["C" ']  (p2);
    \end{tikzpicture}
\end{center}
some text
\end{document}
  • @CarLaTeX I used your updated method, but I don't how to modify this part of code \draw[fill=white] ($(Rect)+(-1.5,-0.7)$)rectangle($(Rect)+(1.5,0.7)$) node[midway] (Text){}; \node at (Text) {\begin{minipage}{3cm}\centering Bond\\ worth P \end{minipage}}; two arrows seem has different length. – A.Oreo Oct 16 '17 at 7:12
  • thanks, your answer is pretty good, but it seems much different from my previous code. – A.Oreo Oct 16 '17 at 7:14
  • @CarLaTeX, which i haven't ... – Zarko Oct 16 '17 at 7:14
  • @A.Oreo, of course, code is completely different, far more clean, simple and concise :-). – Zarko Oct 16 '17 at 7:16
  • @CarLaTeX just copy from previous question. – A.Oreo Oct 16 '17 at 7:33
5

Edited with the new style and added shadows:

All you need is here:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning}
\usetikzlibrary{decorations.markings,calc}
\tikzset{
    process/.style={
        inner sep=0,
        text width=2.5cm, draw,
        minimum height=1.6cm,
        text centered,
        },
    process1/.style={
        text width=2.5cm, draw,
        minimum height=0.8cm,
        text centered,
        },
    description/.style={
        text centered,
        text width=10cm,
    },
    myarrow/.style={
        postaction={
            decorate, decoration={
                markings,mark=at position #1 with {\arrow{Stealth};
                }
            }
        }
    },
}
\usepackage{setspace}
\usepackage{etoolbox}
\AtBeginEnvironment{tikzpicture}{\singlespacing}

\begin{document}

\pagestyle{empty}
\begin{center}
    \begin{tikzpicture}
    \fill[black!20!white] ($(-1.25,-0.8)+(0.25,-0.2)$)rectangle($(1.25,0.8)+(0.25,-0.2)$);
    \node[process,fill=white](p1) at(0,0) {Default\\ protection\\ buyer};
    \fill[black!20!white] ($(7.25,-0.8)+(0.25,-0.2)$)rectangle($(9.75,0.8)+(0.25,-0.2)$);
    \node[process, right=6cm of p1,fill=white]  (p2) {Default\\ protection\\ seller};

    \fill[black!20!white] ($(2.95,0.4)+(0.25,-0.2)$)rectangle($(5.5,2.05)+(0.25,-0.2)$);
    \draw[-Stealth] ([yshift=8ex, xshift=-7ex]p1.east) -- node[process,fill=white] {90 basis points per year} ([yshift=8ex, xshift=7ex]p2.west);
    \draw[-Stealth, line width=1pt] ([yshift=-8ex, xshift=7ex]p2.west) -- node[description, above] {100} ([yshift=-8ex, xshift=-7ex]p1.east);

    \end{tikzpicture}
\end{center}

\begin{center}
    \begin{tikzpicture}
    \fill[black!20!white] ($(-1.25,-0.8)+(0.25,-0.2)$)rectangle($(1.25,0.8)+(0.25,-0.2)$);
    \node[process,fill=white] (p1) at (0,0) {Asset Swap\\ Seller};
    \fill[black!20!white] ($(4,-0.8)+(0.25,-0.2)$)rectangle($(6.6,0.8)+(0.25,-0.2)$);
    \node[process, right=8em of p1,fill=white]  (p2) {Asset Swap\\ Buyer};
    \fill[black!20!white] ($(8,-0.4)+(0.25,-0.2)$)rectangle($(10.7,0.4)+(0.25,-0.2)$);
    \node[process1, right=4em of p2,fill=white]  (p3) {Bond};

    \draw[-Stealth] ([yshift=2ex]p1.east) -- node[description, above] {C} ([yshift=2ex]p2.west);
    \draw[-Stealth] ([yshift=-2ex]p2.west) -- node[description, below] {LIBOR + S} ([yshift=-2ex]p1.east);
    \draw[-Stealth] (p3.west) -- node[description, below] {C} (p2.east);
    \draw[dashed] ($(p1.south west)-(1,0.5)$)rectangle($(p2.north east)+(1,0.5)$);
    \draw[ultra thick] ($(p3)-(1.2,-0.7)$)--($(p3)+(1.2,-0.7)$);
    \draw[ultra thick] ($(p3)-(1.2,0.7)$)--($(p3)+(1.2,0.7)$);
    \end{tikzpicture}
\end{center}

\end{document} 

The new stuff from the previous is that for the rectangle we give two opposite corners and the word rectangle between them. (I filled it white to delete the previous part of the arrow that was there). Also, dashed option works for rectangle as for lines. Finally adding cordinates to a point gives as the opportunity to draw lines or shapes by using known coordinates.

For the shadows it would be easier to not have a code with starting point and shifts are not really helping (right=of and right of are not really appropriate for such cases)

Output:

enter image description here

  • I update code, but there are some problem in\draw [-Stealth, line width=1pt]([yshift= 8ex,xshift=0.5cm]$(p1)$) --node[midway] (Rect){}([yshift=8ex,xshift=-.5cm]$(p2)$); \draw[fill=white] ($(Rect)+(-1.5,-0.7)$)rectangle($(Rect)+(1.5,0.7)$) node[midway] (Text){}; \node at (Text) {\begin{minipage}{3cm}\centering two arrows may have some difference in length, how to set the length here? – A.Oreo Oct 16 '17 at 7:06
  • @A.Oreo... have you resolved your problem? I didn't understood what you want. Please edit your question to add an update with your current problem – koleygr Oct 23 '17 at 21:26

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.