#Duplicated image with same index

7 messages · Page 1 of 1 (latest)

prime creek
#

I have a document in which I add images. I'd like all the images (appendices) I've added to my document to be duplicated in the same format in a dedicated section to group together all the document's appendices. For example when I add my figure (which can be a table, image, ...) #figure(...)<myimage> I would like to show the image, be able to still use the reference in my text with @myimage and then to have it duplicated into my section "All Images" of my document.

I've tried to use state in my template like bellow, but it only show the reference, not the image with the caption and everything.
main.typ

#appendix[
  #figure(
    image("myimage.png"),
    caption: [myimage]
  )<myimage>
]

template.typ

#let appendixes = state("appendixes", ())

[...] // Some other style
for body in appendixes.final(loc) {        
  body
}
[...]

#let appendix(body) = appendixes.update(it => it + (body,))

Anyone would have a clue on how I can achieve this ?

small fjord
#

?r
Maybe you can get what you need with query? For example:

= Section

Some text, @myimage-1.


= Appendix 1

#figure([Image 1], caption: [my image 1]) <myimage-1>

= Appendix 2

#figure([Image 2], caption: [my image 2]) <myimage-2>

= All images

#context query(figure).sum()
prime creek
#

Damn your a king, I've spent about 6 hours trying to figure this out 😭
Thx you so much !

#

Still new to this, I'm trying to learn 🤓

small fjord
#

you're welcome!

#

note that you can manipulate as you wish the array of figures returned by query (just put context in front of the whole code block), here I'm using sum as a shortcut to concatenate all the figure blocks but you might want to do something more complicated