Skip to content

"error: cannot divide by zero" when using a plot inside of tablex  #345

@PhilHelix

Description

@PhilHelix

First off, thank you for this project, it has helped me tons!
However I'm getting the following error whenever I want to plot a function inside of a #tablex(), however this doesn't happen when working with a stock #table().

The versions used were:

  • "@preview/cetz:0.1.2"
  • "@preview/tablex:0.0.6"
error: cannot divide by zero
    ┌─ @preview/cetz:0.1.2/src/util.typ:117:12
    │
117 │       float(num / ctx.length)
    │             ^^^^^^^^^^^^^^^^

help: error occurred in this call of function `resolve-number`
    ┌─ @preview/cetz:0.1.2/src/draw.typ:831:20
    │
831 │       let padding = util.resolve-number(ctx, style.padding)
    │                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this function call
   ┌─ @preview/cetz:0.1.2/src/canvas.typ:97:20
   │
97 │       coordinates = (element.transform-coordinates)(ctx, ..coordinates)
   │                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `process-element`
   ┌─ @preview/cetz:0.1.2/src/canvas.typ:58:14
   │
58 │       let r = process-element(child, ctx)
   │               ^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `process-element`
   ┌─ @preview/cetz:0.1.2/src/canvas.typ:58:14
   │                                                                                                                                                                                                                                           ^58 │       let r = process-element(child, ctx)
   │               ^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `process-element`
   ┌─ @preview/cetz:0.1.2/src/canvas.typ:58:14
   │
58 │       let r = process-element(child, ctx)
   │               ^^^^^^^^^^^^^^^^^^^^^^^^^^^

help: error occurred in this call of function `process-element`
    ┌─ @preview/cetz:0.1.2/src/canvas.typ:276:12
    │
276 │     let r = process-element(element, ctx)
    │             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

A minimal (not) working example would be:

#import "@preview/cetz:0.1.2"
#import "@preview/tablex:0.0.6": tablex

#tablex(cetz.canvas({
  import cetz.plot
  plot.plot({
    plot.add(domain: (1, 2), x=>{ x })
  })
}))

Is this an error fixable on your end or is this more a tablex related issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🐛Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions