Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend functionality of repeat #2713

Open
EpicEricEE opened this issue Nov 18, 2023 · 3 comments
Open

Extend functionality of repeat #2713

EpicEricEE opened this issue Nov 18, 2023 · 3 comments
Labels
layout Related to layout, positioning, etc. proposal You think that something is a good idea or should work differently.

Comments

@EpicEricEE
Copy link
Contributor

EpicEricEE commented Nov 18, 2023

Description

The repeat function currently always justifies its content, and does not allow setting a gap between the repeated items. Instead, to add a gap it is necessary to include horizontal spacing inside the repeated item (as in #repeat[.#h(4mm)]), which however also includes that spacing in the last element.

I propose the following arguments:

image

This would also allow integration with align. Alternatively, it might be better to get the justify property from the current style set for par:

#show repeat: set par(justify: true)
#repeat(gap: 4mm, sym.dot.c)

As a workaround, it is relatively easy to write this function in pure typst as I've done here.

Use Case

Prevent misaligned dots in outline filler:

image

@EpicEricEE EpicEricEE added the feature request New feature or request label Nov 18, 2023
@laurmaedje laurmaedje added layout Related to layout, positioning, etc. proposal You think that something is a good idea or should work differently. and removed feature request New feature or request labels Nov 18, 2023
@Dherse
Copy link
Sponsor Collaborator

Dherse commented Nov 18, 2023

I would mention that I am currently working on pattern fills to get closer to closing #2282 and it may provide the feature you're looking for in a very efficient way (file size wise) without changing any syntax. I am not saying that I am against this idea, I think it's a good one, but since there's overlap and I feel compelled to mention it.

@Dherse
Copy link
Sponsor Collaborator

Dherse commented Nov 22, 2023

Now that #2740 is open, I can tell you that it would look like the following:

#box(
  width: 1fr,
  height: 1em,
  stroke: orange.lighten(90%),
  fill: pattern((12pt, 12pt), spacing: (4mm, 12pt), sym.dot.c)
)

And render to the following:

image

(the orange outline is just for visualizing where the box is)

It's not quite as nice as what you suggested but it will now be possible without requiring any call to layout or style which can slow down document compilation.

@lkndl
Copy link

lkndl commented Dec 16, 2023

I find patterns pretty tricky to get right along both axes; especially because sym.dot apparently has an opaque white background. In particular, it would also cut off the repeated element mid-pattern wherever space runs out, so I think it might be worthwile to implement the par-dependent justify for repeat and possibly also gap. If this were part of the compiler, would the layout/style disadvantage still persist?

Also: sorry for not searching for this issue before opening #2816 😬 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
layout Related to layout, positioning, etc. proposal You think that something is a good idea or should work differently.
Projects
None yet
Development

No branches or pull requests

4 participants