#Rectangles at the edges of the paper / page
17 messages · Page 1 of 1 (latest)
there are a few ways you could approach this:
- use a grid: basically, give it five columns and five rows. the outermost cols/rows should have fixed width/height, the center one should fill the available space (using
columns: (..., 1fr, ...)andh(1fr), respectively). then fill the correct cells with color
- use polygons and move them: there are the functions
rotateandplacethat you can use to move stuff around. define the polygon once, then use those to put four instances of it in the corners. you can use100%as the coordinates so that you don't need to know the page width/height.
- like 2, but use an SVG image that you prepare outside Typst so that you're more flexible with what you can put in the corners.
(1 is least flexible so I probably wouldn't use it unless you know that you don't want any other shapes)
lmk if you struggle anywhere, and I'll help you getting to your goal (absolute positioning can be somewhat tricky) 🙂
Thanks, I'll try and go with the second solution 🙂
maybe also worth mentioning: depending on the symmetries, scale may be better than rotate for your goal.
@raven sail So I've managed to do it :), but it seems my content is offset by some value due to the rectangles from the top and possibly on the bottom as well.
#let global_margin = 2.5cm
#set page(margin: global_margin, paper: "a4")
#set text(font: "New Computer Modern", weight: "regular")
#let corner(where, dx, dy, rot) = place(where, dx: dx, dy: dy, float: true, clearance: 0pt,
rotate(rot,
polygon(
fill: black,
(0.0cm, 0.0cm),
(1.0cm, 0.0cm),
(1.0cm, 0.5cm),
(0.5cm, 0.5cm),
(0.5cm, 1cm),
(0cm, 1cm),
)))
#corner(top + left, -global_margin, -global_margin, 0deg)
#corner(top + right, global_margin, -global_margin - 1cm, 90deg)
#corner(left + bottom, -global_margin, global_margin + 1cm, 270deg)
#corner(right + bottom, global_margin, global_margin, 180deg)
#rect(fill: blue, width: 100%, height: auto)[
#lorem(450)]
Commands:
?render Render Typst code as an image.
/help Show this menu.
/source Get a link to the bot's source.
?ast Get the AST for the given code.
/version Show the bot's Typst version.
/tag Print the content of a tag by name.
/set-tag Set the content of a tag (privileged).
/delete-tag Delete a tag (privileged).
/tags List all tags.
Type ?help command for more info on a command.
You can edit your message to the bot and the bot will edit its response.
Commands prefixed with / can be used as slash commands and prefix commands.
Commands prefixed with ? can only be used as prefix commands.
The bot is written by mattf_. Feel free to reach out in the Typst Discord if you have any questions.
?render ```#let global_margin = 2.5cm
#set page(margin: global_margin, paper: "a4")
#set text(font: "New Computer Modern", weight: "regular")
#let corner(where, dx, dy, rot) = place(where, dx: dx, dy: dy, float: true, clearance: 0pt,
rotate(rot,
polygon(
fill: black,
(0.0cm, 0.0cm),
(1.0cm, 0.0cm),
(1.0cm, 0.5cm),
(0.5cm, 0.5cm),
(0.5cm, 1cm),
(0cm, 1cm),
)))
#corner(top + left, -global_margin, -global_margin, 0deg)
#corner(top + right, global_margin, -global_margin - 1cm, 90deg)
#corner(left + bottom, -global_margin, global_margin + 1cm, 270deg)
#corner(right + bottom, global_margin, global_margin, 180deg)
#rect(fill: blue, width: 100%, height: auto)[
#lorem(450)]```
Setting float to false and tweaking the values give a better result