GithubHelp home page GithubHelp logo

hydra's Introduction

rust & typst enthusiast

hydra's People

Contributors

caemor avatar tingerrr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hydra's Issues

search goes out of scope

I'm building alternating page headers showing the current chapter on even, and the current section on odd pages. Here is a small example:

#import "@preview/hydra:0.2.0": hydra

#set heading(numbering: "1.1")
#show heading.where(level: 1): it => pagebreak(weak: true) + it
#set par(justify: true)

#set page(paper: "a7",
  header: locate(loc => {
    if calc.even(loc.page()) {
      hydra(sel: heading.where(level: 1))
    } else {
      [#h(1fr)#hydra(sel: heading.where(level: 2))]
    }
  }),
)

= First chapter
#lorem(10)
== First chapter first section
#lorem(150)
== First chapter second section
#lorem(20)
= Second
#lorem(10)
=== Second chapter first subsection
#lorem(30)
=== Second chapter second subsection
#lorem(40)

As you can see, the header on the last page refers to First chapter first section; but this is wrong because we're now in Second chapter. Are you ok with a PR if I can fix this (make hydra not cross higher-level headings), or do you think waiting for the "new features for general handling of headings" is better?

Second thing, not a bug:
If you have a look at Second chapter, what do you think about a descend-until-level: 3 option? (I felt ridiculous giving Motivation and Outline full section status ๐Ÿคช )

Wrong heading with `figure(placement: auto)`

Without placement auto, hydra correctly does not display Heading 1 in the header :
image

But when using placement auto, the image is placed at the top and hydra interprets this as being part of section 1 :
image

Maybe it's related to #16.

`skip-starting: false` will not work in the presence of leading ancestors

Given a document like so:

#import "@preview/hydra:0.3.0": hydra
#let hdyra = hydra.with(paper: "a7")

#set page(
  paper: "a7",
  flipped: true,
  width: 100pt,
  header: hydra(skip-starting: false, 2),
)

= Chapter
#lorem(5)

#pagebreak()
// = Chapter
== Section
#lorem(5)

The following two pages are rendered:
image

If the second // = Chapter is no longer commented out, the header on page 2 disappears. This will remain an issue until typst allows us to check the structure of the document more thoroughly to really ensure the first content of a page is the primary element, any of its ancestors or spacing/layout content.

Improve documentation

Add a tidy generated manual and add more specific examples to explain specific use cases such as is-book.

Starting page redundancy check fails in the presence of some `heading` show rules

Given a show rule which introduces an "invisible" element such as v(...) before the heading, the margin redundancy check fails, causing hydra to display the last heading on a page which starts with a new heading.

#import "@preview/hydra:0.4.0": hydra

#set page(header: context hydra(1))
#set heading(numbering: "1.1")

#show heading.where(level: 1) : it => pagebreak(weak: true) + {
  // uncommenting this or adding a block around this whole rule fixes the issue
  // metadata(())
  v(1em)
  it
}

= First
#lorem(10)

= Second
#lorem(10)

#pagebreak()
#lorem(10)

To work around this, consider surrounding your headings with a container, i.e. a block or box, avoid using metadata as it is likely not intended to cause the location collapse, see the upstream issue.

Upstream issue: typst#4029.
Supersedes #2.

Panic on zero margin

If the margin is set to be zero-sized, hydra panics, thinking it's outside the header and there is no anchor.

Some `show` rules break redundancy check

With some show rules for vertical spacing on first-level headings, omitting block wrapping breaks the redundancy check. Adding the block back fixes the issue.

#import "@preview/hydra:0.2.0": hydra

#set page(header: hydra(
  display: (_, it) => {
    if it.numbering != none [
      Chapter #counter(heading).display()
    ]
    it.body
  })
)
#set heading(numbering: "1.1")

// if the block is removed this will no longer check for redundancy correctly,
// some of the spacing also subtly changes.
#show heading.where(level: 1) : it => pagebreak(weak: true) + block({
  set text(2em, weight: "bold")
  v(8em)
  if it.numbering != none [
    Chapter #counter(heading).display()
    #v(.5em)
  ]
  it.body
  v(0.5em)
})

= First
asda

= Second
a

= Third
asd

#pagebreak()

asdas

Removing the block will cause each page to reference its next section instead of the last/none.

Allow alternate active selection

Some users have expressed the desire to select the last heading on the current page over what hydra currently considers the active element, if one exists.

Empty pages get incorrect candidates

Given a document like so:

#import "@preview/hydra:0.4.0": hydra
#show heading.where(level: 1): it => pagebreak(weak: true) + it
#set page(paper: "a7", flipped: true, width: 100pt, header: context hydra(1))

= Incorrect

= Correct
#hide[.]

renders the following two pages:
image

Where the first page incorrectly shows the next heading. This seems to be directly correlated to typst#2631.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.