TransWikia.com

How to put a figure at the middle of a diagram?

TeX - LaTeX Asked on December 31, 2021

I need to produce a diagram where I can put a picture of a brain in the middle of the diagram as follows:

enter image description here

My working trial is as follows:

documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix}

usetikzlibrary{arrows,matrix,positioning,shapes,arrows,fit,shapes.geometric,calc, intersections}
newcommand{tikznode}[2]{relax
    ifmmode%
    tikz[remember picture,baseline=(#1.base),inner sep=0pt] node (#1) {$#2$};
    else
    tikz[remember picture,baseline=(#1.base),inner sep=0pt] node (#1) {#2};%
    fi}
%

begin{document}
    
begin{figure}[!h]
    centering
    begin{tikzpicture}
    [
    squarednode/.style={%
        rectangle,
        draw=black!60,
        fill=white,
        very thick,
        minimum size=5mm,
        text centered,
        text width=1.5cm,
    }
    ]
    %Nodes
    node[squarednode]      (maintopic)                              {BM};
    node[squarednode]      (uppersquare)       [above=of maintopic] {MC};
    node[squarednode]      (rightsquare)       [right=2.5cm of maintopic] {FM};
    node[squarednode]      (lowersquare)       [above=of rightsquare] {TM};
    
    %Lines
    draw[->] (uppersquare.south) -- node[anchor=east] {} (maintopic.north);
    draw[->] (maintopic.east) -- node[anchor=south] {} (rightsquare.west);
    draw[->] (rightsquare.north) -- node[anchor=west] {} (lowersquare.south);
    draw[->] (uppersquare.east) -- (lowersquare.west);
    end{tikzpicture}
    caption{The model of $FTTM$.}
    label{figure:FTTM}
end{figure}

end{document}

that produces:

enter image description here

The picture that I want to put in the middle of the diagram is:

enter image description here

How can I achieve this?

2 Answers

For compare purpose.

Compile with Asymptote.

settings.tex="pdflatex"; // This command is very important!
size(5cm,4cm,false);
defaultpen(fontsize(10pt));
label(graphic("brain.jpg" ,"width=3cm"),(0,0)); // in the same folder.
layer();
label("BM",(-10,-10));
label("MC",(-10,10));
label("TM",(10,10));
label("FM",(10,-10));
draw((-10,-10)--(10,-10),Arrow,Margin(7,7));
draw((10,-10)--(10,10),Arrow,Margin(7,7));
draw((-10,10)--(-10,-10),Arrow,Margin(7,7));
draw((-10,10)--(10,10),dashed,Arrow,Margin(7,7));
shipout(bbox(2mm,FillDraw(white)));

enter image description here

The output is .pdf file and then using includegraphics command normally.

Answered by user213378 on December 31, 2021

The following could get you started. I have added the image first and arranged the boxes reltive to the image:

enter image description here

documentclass{article}
usepackage{tikz}
usetikzlibrary{matrix}

usetikzlibrary{arrows,matrix,positioning,shapes,arrows,fit,shapes.geometric,calc, intersections}
newcommand{tikznode}[2]{relax
    ifmmode%
    tikz[remember picture,baseline=(#1.base),inner sep=0pt] node (#1) {$#2$};
    else
    tikz[remember picture,baseline=(#1.base),inner sep=0pt] node (#1) {#2};%
    fi}
%

begin{document}
    
begin{figure}[!h]
    centering
    begin{tikzpicture}
    [
    squarednode/.style={%
        rectangle,
        draw=black!60,
        fill=white,
        very thick,
        minimum size=5mm,
        text centered,
        text width=1.5cm,
        node distance=0.25cm
    }
    ]
    %Nodes
    node (brain) {includegraphics[width=3cm]{example-image}};
    node[squarednode]      (maintopic)         [below left=of brain]{BM};
    node[squarednode]      (uppersquare)       [above left=of brain] {MC};
    node[squarednode]      (rightsquare)       [below right=of brain] {FM};
    node[squarednode]      (lowersquare)       [above right=of brain] {TM};
    
    %Lines
    draw[->] (uppersquare.south) -- node[anchor=east] {} (maintopic.north);
    draw[->] (maintopic.east) -- node[anchor=south] {} (rightsquare.west);
    draw[->] (rightsquare.north) -- node[anchor=west] {} (lowersquare.south);
    draw[->] (uppersquare.east) -- (lowersquare.west);
    end{tikzpicture}
    caption{The model of $FTTM$.}
    label{figure:FTTM}
end{figure}



end{document}

Answered by leandriis on December 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP