Skip to content

Commit

Permalink
Allow reference chapter with heading
Browse files Browse the repository at this point in the history
  • Loading branch information
flavio20002 committed Oct 4, 2024
1 parent 86d8497 commit 73e77d0
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 23 deletions.
28 changes: 12 additions & 16 deletions lib.typ
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#let title2 = 1.5em
#let title3 = 1.3em
#let title4 = 1.2em
#let title5 = 1.1em
#let title5 = 11pt

#let outline-part = 1.5em;
#let outline-heading1 = 1.3em;
Expand All @@ -41,15 +41,6 @@
#let part-counter = counter("part-counter")
#let part-change = state("part-change", false)


// pagebreak(to: "odd") is not working correctly
#let pagebreak-until-odd() = {
pagebreak()
counter(page).display(i => if calc.even(i) {
pagebreak()
})
}

#let part(title) = {
pagebreak(to: "odd")
part-change.update(x =>
Expand Down Expand Up @@ -91,7 +82,6 @@
}

#let chapter(title, image:none, l: none) = {
pagebreak(to: "odd")
heading-image.update(x =>
image
)
Expand All @@ -100,8 +90,11 @@
] else [
#heading(level: 1, title)
]
part-change.update(x =>
false
}

#let update-heading-image(image:none) = {
heading-image.update(x =>
image
)
}

Expand Down Expand Up @@ -135,7 +128,6 @@
}

#let my-bibliography(file, image:none) = {
pagebreak-until-odd()
counter(heading).update(0)
heading-image.update(x =>
image
Expand Down Expand Up @@ -345,6 +337,7 @@
set text(size: title5)
let page_number = counter(page).at(loc).first()
let odd_page = calc.odd(page_number)
let part_change = part-change.at(loc)
// Are we on an odd page?
// if odd_page {
// return text(0.95em, smallcaps(title))
Expand All @@ -353,7 +346,7 @@
// Are we on a page that starts a chapter? (We also check
// the previous page because some headings contain pagebreaks.)
let all = query(heading.where(level: 1), loc)
if all.any(it => it.location().page() == page_number) {
if all.any(it => it.location().page() == page_number) or part_change {
return
}
let appendix = appendix-state.at(loc)
Expand Down Expand Up @@ -420,6 +413,7 @@
show heading: it => {
set text(size: font-size)
if it.level == 1 {
pagebreak(to: "odd")
//set par(justify: false)
counter(figure.where(kind: image)).update(0)
counter(figure.where(kind: table)).update(0)
Expand Down Expand Up @@ -463,6 +457,9 @@
v(1.5cm, weak: true)
}
})
part-change.update(x =>
false
)
}
else if it.level == 2 or it.level == 3 or it.level == 4 {
let size
Expand Down Expand Up @@ -525,7 +522,6 @@
#it
]
show par: set block(spacing: 2em)
pagebreak()
align(bottom, copyright)
}

Expand Down
1 change: 0 additions & 1 deletion my-index.typ
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ figure(
return ct
}

pagebreak(to: "odd")
set par(first-line-indent: 0em)
locate(loc => {
let main-color = main-color-state.at(loc)
Expand Down
10 changes: 4 additions & 6 deletions my-outline.typ
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
]
}

#let my-outline(appendix-state, part-state, part-location,part_change,part-counter, main-color, textSize1:none, textSize2:none, textSize3:none, textSize4:none) = {
#let my-outline(appendix-state, part-state, part-location,part-change,part-counter, main-color, textSize1:none, textSize2:none, textSize3:none, textSize4:none) = {
show outline.entry: it => {
let appendix-state = appendix-state.at(it.element.location())
let numberingFormat = if appendix-state != none {"A.1"} else {"1.1"}
Expand All @@ -31,9 +31,9 @@
if it.level == 1 {
let part-state = part-state.at(it.element.location())
let part-location = part-location.at(it.element.location())
let part_change = part_change.at(it.element.location())
let part-change = part-change.at(it.element.location())
let part-counter = part-counter.at(it.element.location())
if (part_change){
if (part-change){
v(0.7cm, weak: true)
box(width: 1.1cm, fill: main-color.lighten(80%), inset: 5pt, align(center, text(size: textSize1, weight: "bold", fill: main-color.lighten(30%), numbering("I",part-counter.first()))))
h(0.1cm)
Expand All @@ -55,11 +55,10 @@
my-outline-row(textWeight: "regular", textSize: textSize4, textColor:black, number: number, title: title, heading_page: heading_page, location: it.element.location())
}
}
pagebreak(to: "odd")
outline(depth: 3, indent: false)
}

#let my-outline-small(partTitle, appendix-state, part-state, part-location,part_change,part-counter, main-color, textSize1:none, textSize2:none, textSize3:none, textSize4:none) = {
#let my-outline-small(partTitle, appendix-state, part-state, part-location,part-change,part-counter, main-color, textSize1:none, textSize2:none, textSize3:none, textSize4:none) = {
show outline.entry: it => {
let appendix-state = appendix-state.at(it.element.location())
let numberingFormat = if appendix-state != none {"A.1"} else {"1.1"}
Expand Down Expand Up @@ -98,7 +97,6 @@
#link(it.element.location(),heading_page)
]
}
pagebreak(to: "odd")
outline(
title: list-of-figure-title,
target: target,
Expand Down
Binary file modified tests/long-part-title/ref14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/long-part-title/ref18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/long-part-title/ref22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/long-part-title/ref24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/long-part-title/ref26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/long-part-title/ref28.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/long-part-title/ref30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/sample-book/ref18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73e77d0

Please sign in to comment.