0

What I'm trying to do is to put an equation inside an fbox.
Here's my MWE:

\documentclass[12pt]{article}
\usepackage[italian]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath, amsthm, amssymb, amsfonts}
\usepackage{tikzsymbols}
\usepackage{tikz}

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};} \tikzset{square arrow/.style={ to path={-- ++(0,-.25) -| (\tikztotarget) \tikztonodes},below,pos=.25}}

\begin{document} \noindent\fbox{ \parbox{\textwidth}{ \begin{equation} \underline{Ricorda}: \text{dalla densità}\tikzmark{ddc} \text{ congiunta} \xrightarrow{\text{ricavo}} \text{le densità}\tikzmark{dm} \text{ marginali} \tikz[overlay,remember picture]{\draw[->,square arrow] (dm.south) to node{\text{non ho informazioni sulla dipendenza}} (ddc.south);} \end{equation} } } \end{document}

Since I needed a square arrow, I borrowed the idea from this answer.
My main problem now is that the equation works properly, but the to node{\text{non ho informazioni sulla dipendenza}} part is out of the box as you can see in the following picture

enter image description here

Have you got any idea why this happens?
Thanks in advance

1 Answers1

2

What about the following?

enter image description here

Instead of an equation* environment, I used tikz nodes to place the text and the horizontal arrow. Since all texts are already inside of tikz nodes, there is no need for tikz marks and remember overlay any more. Instead of fbox, I used a costumized tcolorbox environment which at the sametime makes sure, the bo is exactly as wide as the available textwidth.

\documentclass[12pt]{article}

\usepackage{tikz} \usetikzlibrary{positioning, arrows.meta}

\tikzset{square arrow/.style={ to path={-- ++(0,-.25) -| (\tikztotarget) \tikztonodes},below,pos=.25}}

\usepackage[most]{tcolorbox} \newtcolorbox{myframe}{ boxrule=1pt, colback=white, sharp corners, } \begin{document} \begin{myframe} \centering \begin{tikzpicture} \node(A1){{\itshape\underline{Ricorda}}:}; \node(A)[right= 0cm of A1]{dalla densità congiunta}; \node(B)[right= 2cm of A]{le densità marginali}; \draw[->] (A) -- node [above,midway] {\footnotesize ricavo} (B); \draw[->,square arrow] (B.south) to node{\footnotesize non ho informazioni sulla dipendenza} (A.south); \end{tikzpicture} \end{myframe} \end{document}

leandriis
  • 62,593