vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
532 stars 89 forks source link

Feature suggestion: baseline specification for inclusion in LaTeX #457

Open user202729 opened 2 months ago

user202729 commented 2 months ago

TikZ has this thing. https://tikz.dev/tikz-scopes#pgf./tikz/baseline

Can we do the same thing in Asymptote (i.e. in asypictureB or asymptote LaTeX package)?

(Rationale: it's listed in https://tex.stackexchange.com/questions/39577/what-are-the-relative-strengths-of-tikz-and-asymptote as one of the arguments against Asymptote.)


I can see an immediate problem: PDF does not provide any way to draw outside the bounding box (is there? I don't know of one).

So you need to pass the parameter of how much to lower the box to the TeX side, then we can simply do https://tex.stackexchange.com/questions/15853/vertical-alignment-of-inline-images .

I can think of two options:

charlesstaats commented 2 weeks ago

To elaborate on the rationale: the exact quote from the stackexchange answer is "you can define the baseline of TikZ pictures so you can align them neatly." So the desired behavior would be to put asymptote pictures side-by-side and easily set then to have the same y=0 coordinate, even if one of them extends up and the other extends down. For instance,

\begin{asy}[baseline=0]
unitsize(1cm);
draw((0, 0) -- (1, 1));
\end{asy}
\begin{asy}[baseline=0]
unitsize(1cm);
draw((0, 0) -- (-1, -1));
\end{asy}

should produce this

  /
 /
/ 
      /
     /
    /

rather than this

  /    /
 /    /
/    /

This does seem desirable, but I'm not sure how to make it happen.