Skip to content

Commit

Permalink
Fix references
Browse files Browse the repository at this point in the history
  • Loading branch information
flavio20002 committed Oct 2, 2024
1 parent 051ec66 commit 86d8497
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
6 changes: 3 additions & 3 deletions example/main.typ
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ Lists are useful to present information in a concise and/or ordered way.
== Ligatures
fi fj fl ffl ffi Ty

== Referencing Chapters
== Referencing Chapters<heading1>
#index("Referencing")
This statement references to another chapter @chap1
This statement references to another chapter @chap1. This statement references to another heading @heading1. This statement references to another heading @heading2.

#part("Part Two Title")

#chapter("Mathematics", image: image("./orange2.jpg"))

== Theorems
#index("Theorems")
=== Several equations
=== Several equations<heading2>
#index("Theorems!Several equations")
This is a theorem consisting of several equations.
#theorem(name: "Name of the theorem")[
Expand Down
18 changes: 16 additions & 2 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,24 @@
}
return place(dx:-4.5cm, box(width: 4cm, align(right, text(fill: color)[#nums.pos().map(str).join(".")])))
}
},
supplement: supplement-chapter
}
);

show heading.where(level: 1): set heading(supplement: supplement-chapter)

show ref: it => {
let eq = heading
let el = it.element
// let numberingFormat = if appendix-state != none {"A.1"} else {"1.1"} //appendix state must be sourced somehow
let numberingFormat = {"1.1"}
if el != none and el.func() == eq {
let arrayEq = counter(eq).at(el.location())
[#el.supplement #numbering(numberingFormat, ..arrayEq) ]
} else {
it
}
}

show heading: it => {
set text(size: font-size)
if it.level == 1 {
Expand Down
Binary file modified tests/sample-book/ref16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tests/sample-book/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ Lists are useful to present information in a concise and/or ordered way.
== Ligatures
fi fj fl ffl ffi Ty

== Referencing Chapters
== Referencing Chapters<heading1>
#index("Referencing")
This statement references to another chapter @chap1
This statement references to another chapter @chap1. This statement references to another heading @heading1. This statement references to another heading @heading2.

#part("Part Two Title")

#chapter("Mathematics", image: image("./orange2.jpg"))

== Theorems
#index("Theorems")
=== Several equations
=== Several equations<heading2>
#index("Theorems!Several equations")
This is a theorem consisting of several equations.
#theorem(name: "Name of the theorem")[
Expand Down

0 comments on commit 86d8497

Please sign in to comment.