You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want use typst to compose type that "3 screenshots per page, landscape, images from a folder".
I want typest to behavior like css but the output is pdf. When I trying to achieve this, there are some missing
future:
walk through a folder by given path, return a iterator which yields all file path
render a length-unknown image path list
Use Case
Use typst as a universal type set tool.
Reacted by Andrew Voynov, Janosh Riebesell, Karam Khamis, Dixon Sean Low Yan Feng, Aaron Manning, Vladimir Borel, Olivier Samyn, YouXam, Rolf Bremer, Felipe Raimann and 64 more
Such code will compose some paper of 7 images on it, 3 per page.
But I have a folder of many screenshots, maybe 100 pictures.
Is there some tool(package or module) could handle these scanery?
Reacted by Vilém Zouhar, PaulS, Karam Khamis and Luana
I'm not yet completely decided, but I'm open to discussing it. It should of course be restricted to the project/package directory like file loading. And there are further design decisions about what exactly it returns (what about folders for instance: is there a way to tell whether an array item is a file or folder). And then we need a good and efficient interface for the World trait.
How about a simple design like this (two new function)
list_dir(path: str): returns a list of strings under the given path, which includes files and sub-folders.
is_dir(path: str): returns whether a path is a directory.
I think this should be a minimum design; if a path is not a directory but a filename, then we should use functions such as "read" (we might also need to add some debug log and throw the error should we read a directory, instead of a file).
My use case for the capability to walk a directory has to do with sorting files based on content and then sorting based on a metric. The requirement for this functionality is for writing a penetration testing report in which I need to walk through a directory and import/include/sort findings based on cvss scores.
Reacted by Martin Renze, Emil Sågfors, Aaron Covrig, RyanFlm, Robin, rbq and j0hann3s
Not sure if this is still on the table, but I thought I'd just mention my use case on the off-chance it helps anyone.
I am designing a recipe book, each recipe is a Yaml file in a sub-dir of the project. My Typst book iterates through the recipes to produce the formatted output. It currently does this with a hard-coded set of paths, but it would be nice to be able to programmatically walk through all the files in that sub-dir that's effectively part of the "source" of the project.
I did think about making the recipes Typst files instead of Yaml, but that wouldn't change much as there does not seem to be any form of glob importing currently. If there is a neat way of doing this already, I don't know about it sorry.
Anyway just my two cents, I still think this issue is relevant!
Reacted by Jan Hensel, PaulS, Stefano Coretta, Karam Khamis, Florian Vincent, Janosh Riebesell, Marius Bär, Nika Sommer, flokl, Martin Renze and 17 more
Reacted by Michael P. Jung, PukNgae Cryolitia, Jakob, Pascal, Antonio De Lucreziis, MagicMan, Runar, Felipe Raimann, Alexander Wörndl, Aaron Covrig and 8 more
Reacted by bbb651 🇮🇱, Vsevolod Shegolev, AYOUB EL MHAMDI, Zaitara, rbq, Valerius Mattfeld, NoBrainSkull, David Lutton, Joseph Alexander Wilson, cstef and 3 more
Reacted by AYOUB EL MHAMDI and Joseph Alexander Wilson
I want to add that such a feature would be very much appreciated! I often had the case where I wanted to load data like result01.csv, result02.csv, ... and plot it, but had to write unconvenient solutions for that.
Reacted by Felipe Raimann, Gwenn Le Bihan, Gaweringo, AYOUB EL MHAMDI, Lachlan Kermode, Nathan, vegabook, Marco Bulgarelli, Dennis Hoelgaard Bal, Bastien Voirin and 1 more
And then we need a good and efficient interface for the World trait.
As I'm still getting to know the ins and outs of Typst. Is the World trait the basic requirement used so that typst watch knows when to recompile the project as assets change?
For a directory walking/glob API, being able to track when files resolved in such a way are updated would be needed to maintain the incredible dependency graph that typst watch is so beautifully able to track.
As I'm still getting to know the ins and outs of Typst. Is the World trait the basic requirement used so that typst watch knows when to recompile the project as assets change?
Essentially yes. As long as the stuff returned by the World trait has the same hash, things are cached.
Just want to chime in and say that I would love this feature.
My use case would be to create a cookbook, where each recipe would be a separate file. I can then section the recipes by folders such as "Desserts", "Dinners", "Bakery" etc, and just include all files in that directory.
Reacted by Bastien Voirin, Aaron Manning and Tamara Cook
As Typst rapidly becomes more suited for building blogs with HTML + bundle export, the ability to list files (e.g. blog posts) in a folder becomes more useful.
Reacted by Tamara Cook, Vsevolod Shegolev, talb, Maxim Lavrinenko, Robin, Aloïs de Gouvello, 卢旺, Youenn Le Jeune, Castanearie, Yavor Kolev and 15 more
While we wait for this feature to be thought out and implemented, here is my workaround:
Create an index file that lists all files in your directory, find is a good fit for it (find -type f > index)
Then in your typst code you can iterate over the lines of index with read:
#forfileinread("index").split("\n").filter(x=>x!="") {
read(file) // or whatever you want to do with the file
}
I have my find command in a make-index.sh file, which I run once in a while. It's not completely automated, but it works well enough for my use case
Reacted by skeletony007, waffle, Robin, Dennis Hoelgaard Bal, Bastien Voirin, Michael P. Jung and Markus Langgeng Iman Saputra
Activity
RuofengX commentedon Sep 13, 2023
Such code will compose some paper of 7 images on it, 3 per page.
But I have a folder of many screenshots, maybe 100 pictures.
Is there some tool(package or module) could handle these scanery?
LuxxxLucy commentedon Sep 13, 2023
I recommend try with the preprocessing approach (using "typst-pyimage") first.
[-]Read all images from a folder and render.[/-][+]Directory walking[/+]LuxxxLucy commentedon Sep 13, 2023
@laurmaedje do we want to implement a function for directory walking?
Maybe adding a interface named "list_dir" which takes a path and returns an array?
laurmaedje commentedon Sep 13, 2023
I'm not yet completely decided, but I'm open to discussing it. It should of course be restricted to the project/package directory like file loading. And there are further design decisions about what exactly it returns (what about folders for instance: is there a way to tell whether an array item is a file or folder). And then we need a good and efficient interface for the
Worldtrait.LuxxxLucy commentedon Sep 23, 2023
How about a simple design like this (two new function)
I think this should be a minimum design; if a path is not a directory but a filename, then we should use functions such as "read" (we might also need to add some debug log and throw the error should we
reada directory, instead of a file).drakeaxelrod commentedon Oct 26, 2023
My use case for the capability to walk a directory has to do with sorting files based on content and then sorting based on a metric. The requirement for this functionality is for writing a penetration testing report in which I need to walk through a directory and import/include/sort findings based on cvss scores.
reed-smout commentedon Jan 22, 2024
Not sure if this is still on the table, but I thought I'd just mention my use case on the off-chance it helps anyone.
I am designing a recipe book, each recipe is a Yaml file in a sub-dir of the project. My Typst book iterates through the recipes to produce the formatted output. It currently does this with a hard-coded set of paths, but it would be nice to be able to programmatically walk through all the files in that sub-dir that's effectively part of the "source" of the project.
I did think about making the recipes Typst files instead of Yaml, but that wouldn't change much as there does not seem to be any form of glob importing currently. If there is a neat way of doing this already, I don't know about it sorry.
Anyway just my two cents, I still think this issue is relevant!
lucifer1004 commentedon Jun 12, 2024
Hi guys, I just made PR #4380 which provides a
readdirfunction. This function returns the names of a directory's contents as an array of strings.renders something like below
("a.txt", "c", "b.json")Thus we can do things like
Doom4535 commentedon Dec 2, 2024
I'd also like to have this ability for automatically including the contents of certain folders into an appendix; my current approach is:
I would much rather be able to just point it at the
matlabfolder and have it add an entry for each file that is present there.ayoubelmhamdi commentedon Mar 21, 2025
i think, the glob function is more convenient like other languages:
terefang commentedon Apr 8, 2025
#6155
bratorange commentedon May 14, 2025
I want to add that such a feature would be very much appreciated! I often had the case where I wanted to load data like result01.csv, result02.csv, ... and plot it, but had to write unconvenient solutions for that.
mewmew commentedon Jul 11, 2025
As I'm still getting to know the ins and outs of Typst. Is the
Worldtrait the basic requirement used so thattypst watchknows when to recompile the project as assets change?For a directory walking/glob API, being able to track when files resolved in such a way are updated would be needed to maintain the incredible dependency graph that
typst watchis so beautifully able to track.laurmaedje commentedon Jul 21, 2025
Essentially yes. As long as the stuff returned by the
Worldtrait has the same hash, things are cached.KronosTheLate commentedon Apr 5, 2026
Just want to chime in and say that I would love this feature.
My use case would be to create a cookbook, where each recipe would be a separate file. I can then section the recipes by folders such as "Desserts", "Dinners", "Bakery" etc, and just include all files in that directory.
skeletony007 commentedon May 1, 2026
I too would like this feature.
So much so that, for Git repositories, I've already written a quick plugin that can walk tree objects:
Jollywatt commentedon May 23, 2026
As Typst rapidly becomes more suited for building blogs with HTML + bundle export, the ability to list files (e.g. blog posts) in a folder becomes more useful.
Myriade-Medieval commentedon Jul 15, 2026
While we wait for this feature to be thought out and implemented, here is my workaround:
Create an
indexfile that lists all files in your directory,findis a good fit for it (find -type f > index)Then in your typst code you can iterate over the lines of
indexwith read:I have my find command in a
make-index.shfile, which I run once in a while. It's not completely automated, but it works well enough for my use casebastienvoirin commentedon Jul 17, 2026
Or simply
:)