Matze
January 26, 2026, 7:48am
1
Hi there!
I am trying to overload the image markdown, so that I can use it with the same styling etc in the whole document.
Here is my code:
#let image(img,
width: 70%, height: auto, fit: auto,
caption: "", reflink: "") = {
align(horizon, [
#figure(
std.image(img,
width: width, height: height),
caption: caption) [<#reflink>]]
)
}
#image("../" + ImageTransfercurve,
caption: "This is the description", reflink: "Transfercurve")
It basically works, except for the image reference. “Transfercurve” is just printed below the image and the caption.
I also tried around with different bracket formattings, but I cannot get it to work in a simple way.
What am I doing wrong?
How to create dynamic reference and label? Does not seem to be same problem, is it?
Matze
January 26, 2026, 8:07am
2
Maybe, I already found the solution by myself:
#let image(img,
width: 70%, height: auto, fit: auto,
caption: "", reflink: "") = {
align(horizon, [
#figure(
std.image(img,
width: width, height: height),
caption: caption) #reflink]
)
}
#image("../" + ImageTransfercurveLIN,
width: 90%,
caption: "This is the description", reflink: <Transfercurve>)
In @Transfercurve, something is shown.
This seems to be working without problems.
Thanks for the support anyway, this forum is a great source of information!
flokl
January 26, 2026, 9:13am
3
To make the code from the question work, you have to use #label(reflink).
#let image(img,
width: 70%, height: auto, fit: auto,
caption: "", reflink: "") = {
align(horizon, [
#figure(
std.image(img,
width: width, height: height),
caption: caption) #label(reflink)]
)
}
1 Like
Matze
January 26, 2026, 10:21am
4
This works as well, but the relevant thing is that I have to pass the Link name with angle brackets <>.
So, in the text, if I use #image, I have to pass reflink: <Transfercurve> to the #figure element instead of reflink: "Transfercurve"
flokl
January 26, 2026, 10:36am
5
I posted the snipped to show that passing the link name as a string (reflink: "Transfercurve") is also possible.
Matze
January 26, 2026, 12:17pm
6
You are right and I will also use it like this. This solution is more straightforward to the user than using angle brackets.
Thanks!
1 Like