Hi there @9iovaferra , welcome to the forum.
Thank you for taking the time to format your code properly and to provide an example.
From what I can see, your code works. It does not compile directly, but here is an example that does:
Reworked Code Snippet that Compiles
// That was missing for the code to compile
#set page(margin: (inside: 2cm, outside: 2.5cm))
#set math.equation(numbering: "1.1")
$ x+1 $ <eq>
//Image to import
#let svg = ```svg
<svg version="1.1" width="20" height="20" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="black" />
<text x="10" y="10" font-size="6" text-anchor="middle" fill="white">SVG</text>
</svg>
```.text
#let logo-b = bytes(svg)
#let scfigure(
caption-ratio: auto,
caption-align: bottom + left,
gutter: 1.6em,
..args,
) = context {
let text-width = page.width - (page.margin.inside + page.margin.outside)
let half-gutter = gutter.to-absolute() / 2
show figure.caption: it => { align(caption-align)[#it] }
show figure.where(kind: image): it => {
let img-size = (width: 50% - half-gutter, height: auto)
if "width" in it.body.fields() {
img-size.width = it.body.width.ratio + (it.body.width.length.to-absolute() / text-width * 100%) - half-gutter
}
if "height" in it.body.fields() {
img-size.height = it.body.height
}
let caption-width = img-size.width.ratio - half-gutter
if img-size.width.ratio > 50% {
caption-width = 100% - img-size.width.ratio - half-gutter
}
if caption-ratio != auto {
caption-width = caption-width.ratio * caption-ratio - half-gutter
}
let columns-arrangement = (img-size.width, caption-width)
align(center, block(breakable: false, above: 2.4em, below: 2.4em)[
#grid(
columns: columns-arrangement,
column-gutter: gutter,
image(
it.body.source, // had to comment this to compile
// .trim("../"),
// img folder is relative to this file now!!
width: 100%,
height: img-size.height,
),
it.caption,
)
])
}
figure(..args)
}
#figure(
image(logo-b, width: 45%),
caption: [Plot of @eq.],
)
#scfigure(
image(logo-b, width: 45%),
caption: [Plot of @eq.],
)
Look in your code for another context expression. You must have something else that you have not provided that creates the issue.
Could you try to provide an example that does bring that error you mentioned?
A good thing to do would be to read more about context, either in the docs or in this forum.
#set math.equation(numbering: "1.1.")
= Test
//Works
$ x + 1 $ <eq>
This is @eq and it works
//Works
#context [
$ x + 2 $ <eq2>
This is @eq2 and it works
]
//Does not work
#context $ x + 3 $ <eq3>
This is @eq3 and it dowes not work // <-- raises an error