Skip to content

support gap bwtween line number and code and support 100% width#25

Open
Yiklek wants to merge 1 commit into
andreasKroepelin:mainfrom
Yiklek:main
Open

support gap bwtween line number and code and support 100% width#25
Yiklek wants to merge 1 commit into
andreasKroepelin:mainfrom
Yiklek:main

Conversation

@Yiklek
Copy link
Copy Markdown

@Yiklek Yiklek commented Oct 20, 2024

Hi Andreas, I would like to extend my heartfelt thanks to the Lovelace package, which has been instrumental in completing my master thesis.

I noticed a small issue that It does not make full use of 100% page width. For example, when I use #h(1fr), it still exists a gap with the edge of the page.

#block(
  fill: luma(230),
  [#lorem(30) #h(1fr)],
)

#line(length: 100%)

#figure(
  kind: "algorithm",
  supplement: [Algorithm],
  pseudocode-list(booktabs: true, numbered-title: [My cool algorithm #h(1fr)],
  indentation: 1em,
  stroke: none,
  )[
    + do something
    + do something else
    + *while* still something to do
      + do even more
      + *if* not done yet *then*
        + wait a bit
        + resume working
      + *else*
        + go home
      + *end*
    + *end*
  ]
)

image

I find it is affected by the parameter indentation . When indentation is 0em, there is no gap, but the code indents become weird.

image

When indentation is a non-zero value, the algorithm width is affected.

2em:
image

5em:
image

I have fixed this issue and added a parameter code-offset to specify the gap between the line numbers and the code. The width is not affected by the parameter indentation and that the code is indented correctly.

#block(
  fill: luma(230),
  [#lorem(30) #h(1fr)],
)

#line(length: 100%)

#figure(
  kind: "algorithm",
  supplement: [Algorithm],
  pseudocode-list(booktabs: true, numbered-title: [My cool algorithm #h(1fr)],
  indentation: 1em,
  code-offset: .5em,
  stroke: none,
  )[
    + do something
    + do something else
    + *while* still something to do
      + do even more
      + *if* not done yet *then*
        + wait a bit
        + resume working
      + *else*
        + go home
      + *end*
    + *end*
  ]
)

image

indentation is set to 2em:

image

code-offset is set to 2em:

image

I'm a typst beginner, please feel free to give me advice.

@andreasKroepelin
Copy link
Copy Markdown
Owner

I'm glad Lovelace is useful for you! The fix looks good on a first glance. I'll have to think through it a bit more though :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants