TransWikia.com

Figure with Tabular to illustrate an equation

TeX - LaTeX Asked on September 30, 2021

I would like to the Dice Coefficient by creating from a visual point of view.
I.e.
The Dice Coefficient is expressed as:

 $D(A,B) &= frac{2 left| A cap B right|}{left| A right| + left| B right|}$

With Tikz I created illustration images using cloud and starburst shapes that I saved.
Now in simplified code I would like to do something like:

d(includegraphics{A.png}, includegraphics{B.png}) = frac{ includegraphics{A_union_B.png} } +  includegraphics{A_union_B.png} }{includegraphics{A.png} + includegraphics{B.png}}

I wrote the following code:

begin{figure}[!ht]
    centering
    begin{tabular}{c c c c c c}
    D(&
    includegraphics{./images/A.png}&
    ,&
    includegraphics{./images/B.png}&
    )=
    &
    multirow{3}[*]{}{includegraphics{images/A_union_B.png} + includegraphics{images/A_union_B.png} 
    hline 
    includegraphics{images/A.png} + includegraphics{images/B.png}}
    % frac{includegraphics{images/A_union_B.png} + includegraphics{images/A_union_B.png} }{ includegraphics{images/A.png} + includegraphics{images/B.png} }
    end{tabular}
    caption{Caption}
    label{fig:my_label}
end{figure}

which does not do what I expect.

I tried also to do it directly using tikz, I got some results but I miss manage the size which drives me to a point where I should have drawn some alphabet letters.

Thanks in advance for any help.

——-EDIT——-

Zarko’s solution allows me to do what I wanted but did not arrived when I posted this question.

What I wanted to do is:

begin{figure}[!ht]
setkeys{Gin}{height=1cm, width=1cm}
[
    Dleft(adjustimage{valign=c}{./images/A.png},adjustimage{valign=c}{./images/B.png} right) = frac{adjustimage{valign=c}{./images/A_union_B.png} +  adjustimage{valign=c}{./images/A_union_B.png}}{adjustimage{valign=c}{./images/A.png} + adjustimage{valign=c}{./images/B.png}}
]
    caption{Caption}
    label{fig:test}
end{figure}

Thank you very much.

One Answer

  • sorry, your question is not clear ... some sketch, what is desired result, would be very helpful
  • you should extend your code fragment to complete small document
  • I guess that you looking for something like this:

enter image description here

documentclass{article}
usepackage[demo,
            export]{adjustbox}

begin{document}
    begin{figure}[!ht]
setkeys{Gin}{height=1cm, width=1cm}
[
    Dfrac{left(adjustimage{valign=c}{./images/A.png}, , adjustimage{valign=c}{./images/B.png} right)}
          {adjustimage{valign=c}{images/A.png} + adjustimage{valign=c}{images/B.png}}
    = adjustimage{valign=c}{images/A_union_B.png} + adjustimage{valign=c}{images/A_union_B.png}
]
    caption{Caption}
    label{fig:my_label}
end{figure}
end{document}

Edit: After editing qustion is clear what you like to have. copying and compiling your new code from your edited question, I got desired result:

enter image description here

Correct answer by Zarko on September 30, 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