Как мне создать следующую иллюстрацию в LaTeX? - PullRequest
1 голос
/ 19 октября 2019

Я попытался создать следующую иллюстрацию в LaTex с плохими результатами. Проблема в том, что я не могу определить начальные и конечные точки стрелок так, как я хочу. Любые предложения / советы, как добиться успеха в этом?

[Illustration of a game theoretic setup

Ответы [ 2 ]

2 голосов
/ 19 октября 2019

Здесь возможна реализация с использованием tikz, с библиотеками calc и позиционирования

\documentclass{article}

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

\begin{document}
  \begin{tikzpicture}[box/.style={
      draw,thick,
    },
    label/.style={draw=none,midway,sloped,above,font=\small},
    myarrow/.style={->,thick} ,
    ]
    %poition upper and lower nodes
    \node[box] (gov) {Government};
    \node[box,below=4cm of gov,minimum width=3cm,dotted] (trans) {Transaction} ;

    % position first line extremity at, say, 1/3 gov node
    \coordinate (extr1) at ($(trans.north west)!0.33!(trans.north east)$) ;
    % then extremity 2 slightly at the right of extr1
    \coordinate (extr2) at ([xshift=2mm]extr1) ;

    % position bank vertically halfway gov/trans and centered wrt extr1 and extr2
    % due to some limitations in tikz parser, one must first define intermediate coords
    \coordinate (extr12) at ($(extr1)!0.5!(extr2)$) ;
    \coordinate (mid) at ($(gov)!0.5!(trans)$);
    \node[box] (bank) at (extr12 |- mid) {Bank};
    % draw first arrows
    \draw[myarrow] (extr1) -- (extr1 |- bank.south) node[label] {information};
    \draw[myarrow] (extr2 |- bank.south) -- (extr2) node[label] {monitoring};
    \draw[myarrow] (extr1 |- bank.north) -- (extr1 |- gov.south) node[label] {reporting} ;
    \draw[myarrow] (extr2 |- gov.south) -- (extr2 |- bank.north) node[label] {fines} ;
    % position last arrow midway from east border of bank and gov
    \coordinate (extr3) at ($(bank.east)!0.5!(gov.east)$) ;
    \draw[myarrow] (extr3 |- gov.south) -- (extr3 |- trans.north) node[label] {investigation} ;
\end{tikzpicture}
\end{document}

enter image description here

Вам необходимо изменить пару параметров для позиционированиячто вы хотите и добавьте стиль к узлам / линиям по мере необходимости.

1 голос
/ 21 октября 2019

Использование north и southphantom) делает все в порядке по вертикали. Вместо этого я хотел использовать библиотеку calc TikZ для более горизонтального смещения конечных точек стрелок от узлов (a), (b), (c) более элегантным способом, но мне это не удалось:

\documentclass[tikz,border=5mm]{standalone}
\usetikzlibrary{arrows,decorations.markings}

\begin{document}
  \begin{tikzpicture}[>=triangle 45, thick, sloped]
    \node [rectangle, very thick, draw, right] (a) at (0,6) {\large\textbf{Government}};
    \node [rectangle, very thick, draw, right] (b) at (0,3) {\large\textbf{Bank}};
    \node [rectangle, densely dotted, draw, right] (c) at (0,0) {\large Transaction};
    \node (d) at (.2,6) {\phantom{G}};
    \node (e) at (.2,3) {\phantom{B}};
    \node (f) at (.2,0) {\phantom{T}};
    \node (g) at (1.1,6) {\phantom{G}};
    \node (h) at (1.1,3) {\phantom{B}};
    \node (i) at (1.1,0) {\phantom{T}};
    \node (j) at (2,6) {\phantom{G}};
    \node (k) at (2,0) {\phantom{T}};
    \draw [->] (e.north) -- (d.south) node[pos=0.5, above] {reporting};
    \draw [->] (g.south) -- (h.north) node[pos=0.5, above] {fines};
    \draw [->] (f.north) -- (e.south) node[pos=0.5, above] {information};
    \draw [->] (h.south) -- (i.north) node[pos=0.5, above] {monitoring};
    \draw [->] (j.south) -- (k.north) node[pos=0.5, above] {investigation};
  \end{tikzpicture}
\end{document}

Этот код приводит к:

screenshot of output image

Тогда вы можете настроить это в зависимости от вашего вкуса!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...