terrastruct / d2

D2 is a modern diagram scripting language that turns text to diagrams.
https://d2lang.com
Mozilla Public License 2.0
17.5k stars 430 forks source link

LaTeX blocks with long lines become decentered and overflow the node bounding box (for some rendering environments) #2083

Closed smheidrich closed 2 months ago

smheidrich commented 2 months ago

Consider:

a: {
  eqn: |latex
    a\\
    super\\ super\\ super\\ super\\ super\\ super\\
    super\\ super\\ super\\ super\\ super\\ super\\
    long\\ equation
  |
}

This will sometimes render OK and sometimes cause the long equation line to be shifted to one side, depending on the rendering environment:

Rendered to an SVG using Dagre on my system
Rendered to an SVG using ELK on my system
Rendered using Dagre in the D2 Playground and exported (same as on my system)

Curiously, it gets shifted in the other direction in the preview panel of the D2 Playground (and the shift is less pronounced so it stays within its bounding box at this length):

Screenshot of the D2 Playground

Nothing of the sort happens when I write similarly long labels for regular non-LaTeX nodes, so this seems to be LaTeX-specific.

System information

Dagre version: 0.6.6 (on my system, no idea what the Playground uses)

alixander commented 2 months ago

can you give more system information? e.g. browser, os

this renders and exports without overflow for me: https://play.d2lang.com/?script=SrRSqOZSUEgtzLNSqMlJLEmt4FJQUFBIjIkB08WlBalFMTHE0mTrycnPS4-JUUgtLE0syczP41JQqOGq5QIEAAD__w%3D%3D&


it does look like it consistently underflows though, e.g. the box is longer than contents

smheidrich commented 2 months ago

@alixander Sure (I didn't realize the Playground export was entirely client-side): Debian 12, Firefox 130.0

But I just tried it on my work machine which runs Ubuntu 22.04 with the same Firefox version and it looked perfect there.

So my guess is this is something specific to my exact system and if I did a fresh install of Debian it would probably be fine.

I'll close this, thanks for looking into it!