smimram / satex

String diagrams in LaTeX.
https://smimram.github.io/satex/
GNU General Public License v3.0
13 stars 3 forks source link

Overlapping of cells and bad positioning of wires #1

Closed SimonForest closed 2 years ago

SimonForest commented 2 years ago

The following example

\documentclass{standalone}
\usepackage{satex}

\deftwocell[rectangle,"="]{eq1to2 : 1 -> 2}
\deftwocell[rectangle,"="]{eq2to2 : 2 -> 2}
\deftwocell["AAA"]{cnode : 2 -> 0}

\begin{document}
$ \twocell{
  (label["A"]* label["A"] * label["A"])
  *
  (eq1to2 * eq2to2)
  *
  (label["A"] * label["A"] * label["A","A"])
  *
  (1 * cnode * 1)
  *
  (eq2to2)
  *
  (label["A","A"])
} $
\end{document}

produces the following output : pb.pdf

As can be seen on the pdf, there are several unexpected behaviors on the output:

I am not sure if I am missing an option or not, but I would have assumed that not having these issues would have been the default behavior.

smimram commented 2 years ago

I have fixed the overlapping boxes. The rest can be fixed as follows:

\documentclass{standalone}
\usepackage{satex}

\deftwocell[rectangle,"="]{eq1to2 : 1 -> 2}
\deftwocell[rectangle,"="]{eq2to2 : 2 -> 2}
\deftwocell["AAA",width=1.6]{cnode : 2 -> 0}

\begin{document}
$ \twocell{
  (label["A","A","A"])
  *
  (eq1to2 * eq2to2)
  *
  (label["A","A","A","A"])
  *
  (1 * cnode * 1)
  *
  (eq2to2)
  *
  (1 * space2 * 1)
  *
  (label["A","A"])
} $
\end{document}

Here is the output.

SimonForest commented 2 years ago

Great, thanks!

For the size of the circle, is it not possible to ask LaTeX to give you the dimensions of the label's box when using \deftwocell and output this information to the .satex so that satex is able to adjust automatically? This would require a more sophisticated definition of \deftwocell though…