diff --git a/src/auxiliary.typ b/src/auxiliary.typ index 2a45db2..43fd48d 100644 --- a/src/auxiliary.typ +++ b/src/auxiliary.typ @@ -1,11 +1,28 @@ #import "./global.typ" : * -#let __g-student-data(show-line-two: true) = { +#let __g-student-data(show-line-two: true, show-group: true, show-date:true) = { locate(loc => { - [#__g-localization.final(loc).family-name: #box(width: 2fr, repeat[.]) #__g-localization.final(loc).given-name: #box(width:1fr, repeat[.])] + [ + #__g-localization.final(loc).family-name: #box(width: 2fr, repeat[.]) + #__g-localization.final(loc).given-name: #box(width:1fr, repeat[.]) + ] + if show-line-two { v(1pt) - align(right, [#__g-localization.final(loc).group: #box(width:2.5cm, repeat[.]) #__g-localization.final(loc).date: #box(width:3cm, repeat[.])]) + align(right, { + if show-group { + __g-localization.final(loc).group + [: ] + box(width:2.5cm, repeat[.]) + [ ] + } + if show-date { + __g-localization.final(loc).date + [: ] + box(width:4cm, repeat[.]) + } + } + ) } } ) @@ -207,105 +224,106 @@ ), show-student-data: "first-page", ) => { - if (page-number==1) { - align(right)[#box( - width:108%, - grid( - columns: (auto, auto), - gutter:0.7em, - align(left + top)[ - #if(type(school) == "dictionary"){ - if(school.at("logo", default : none) != none) { - set image(height:2.5cm, width: 2.7cm, fit:"contain") - if(type(school.logo) == "content") { - school.logo - } - else if(type(school.logo) == "bytes") { - image.decode(school.logo, height:2.5cm, fit:"contain") - } - else { - assert(type(school.logo) in (none, "content", "bytes") , message: "school.logo be of type content or bytes.") - } + if (page-number==1) { + align(right)[#box( + width:108%, + grid( + columns: (auto, auto), + gutter:0.7em, + align(left + top)[ + #if(type(school) == "dictionary") { + if(school.at("logo", default : none) != none) { + set image(height:2.5cm, width: 2.7cm, fit:"contain") + if(type(school.logo) == "content") { + school.logo } - } - ], - grid( - rows: (auto, auto, auto), - gutter:1em, - grid( - columns: (auto, 1fr, auto), - align(left + top)[ - #if(type(school) == "dictionary") [ - #school.at("name", default : none) \ - ] - #exam-info.academic-period \ - #exam-info.academic-level - ], - align(center + top)[ - // #exam-info.number #exam-info.content \ - ], - align(right + top)[ - #exam-info.at("academic-subject", default: none) \ - #exam-info.number \ - #exam-info.content - ], - ), - line(length: 100%, stroke: 1pt + gray), - if show-student-data in (true, "first-page", "odd-pages") { - __g-student-data() + else if(type(school.logo) == "bytes") { + image.decode(school.logo, height:2.5cm, fit:"contain") } - ) - ) - )] - } - else if calc.rem-euclid(page-number, 2) == 1 { + else { + assert(type(school.logo) in (none, "content", "bytes") , message: "school.logo be of type content or bytes.") + } + } + } + ], grid( - columns: (auto, 1fr, auto), - gutter:0.3em, - align(left + top)[ - #if(type(school) == "dictionary") [ - #school.at("name", default : none) \ - ] - #exam-info.academic-period \ - #exam-info.academic-level - ], - align(center + top)[ - // #exam-info.number #exam-info.content \ - ], - align(right + top)[ - #exam-info.at("academic-subject", default: none) \ - #exam-info.number \ - #exam-info.content - ] + rows: (auto, auto, auto), + gutter:1em, + grid( + columns: (auto, 1fr, auto), + align(left + top)[ + #if(type(school) == "dictionary") [ + #school.at("name", default : none) \ + ] + #exam-info.academic-period \ + #exam-info.academic-level + ], + align(center + top)[ + // #exam-info.number #exam-info.content \ + ], + align(right + top)[ + #exam-info.at("academic-subject", default: none) \ + #exam-info.number \ + #exam-info.content + ], + ), + line(length: 100%, stroke: 1pt + gray), + if show-student-data in (true, "first-page", "odd-pages") { + __g-student-data() + } ) - line(length: 100%, stroke: 1pt + gray) - if show-student-data == "odd-pages" { - __g-student-data(show-line-two: false) - } - } - else { - grid( - columns: (auto, 1fr, auto), - gutter:0.3em, - align(left + top)[ - #if(type(school) == "dictionary") [ - #school.at("name", default : none) \ - ] - #exam-info.academic-period \ - #exam-info.academic-level - ], - align(center + top)[ - // #exam-info.number #exam-info.content \ - ], - align(right + top)[ - #exam-info.at("academic-subject", default: none) \ - #exam-info.number \ - #exam-info.content \ + ) + )] + } + else if calc.rem-euclid(page-number, 2) == 1 { + grid( + columns: (auto, 1fr, auto), + gutter:0.3em, + align(left + top)[ + #if type(school) == "dictionary" [ + #school.at("name", default : none) \ ] - ) - line(length: 100%, stroke: 1pt + gray) - } + #exam-info.academic-period \ + #exam-info.academic-level + ], + align(center + top)[ + // #exam-info.number #exam-info.content \ + ], + align(right + top)[ + #exam-info.at("academic-subject", default: none) \ + #exam-info.number \ + #exam-info.content + ] + ) + line(length: 100%, stroke: 1pt + gray) + if show-student-data == "odd-pages" { + __g-student-data(show-line-two: false) + } } + else { + grid( + columns: (auto, 1fr, auto), + gutter:0.3em, + align(left + top)[ + #if type(school) == "dictionary" [ + #school.at("name", default : none) \ + ] + #exam-info.academic-period \ + #exam-info.academic-level + ], + align(center + top)[ + // #exam-info.number #exam-info.content \ + ], + align(right + top)[ + #exam-info.at("academic-subject", default: none) \ + #exam-info.number \ + #exam-info.content \ + ] + ) + line(length: 100%, stroke: 1pt + gray) + } + } + } #let __show-watermark = ( author: ( diff --git a/src/g-exam.typ b/src/g-exam.typ index 313ef9c..677ce9c 100644 --- a/src/g-exam.typ +++ b/src/g-exam.typ @@ -104,105 +104,114 @@ number-align: right, header-ascent: 20%, header:locate(loc => { - let __page-number = counter(page).at(loc).first() - if (__page-number==1) { - align(right)[#box( - width:108%, - grid( - columns: (auto, auto), - gutter:0.7em, - align(left + top)[ - #if(type(school) == "dictionary") { - if(school.at("logo", default : none) != none) { - set image(height:2.5cm, width: 2.7cm, fit:"contain") - if(type(school.logo) == "content") { - school.logo - } - else if(type(school.logo) == "bytes") { - image.decode(school.logo, height:2.5cm, fit:"contain") - } - else { - assert(type(school.logo) in (none, "content", "bytes") , message: "school.logo be of type content or bytes.") - } - } - } - ], - grid( - rows: (auto, auto, auto), - gutter:1em, - grid( - columns: (auto, 1fr, auto), - align(left + top)[ - #if(type(school) == "dictionary") [ - #school.at("name", default : none) \ - ] - #exam-info.academic-period \ - #exam-info.academic-level - ], - align(center + top)[ - // #exam-info.number #exam-info.content \ - ], - align(right + top)[ - #exam-info.at("academic-subject", default: none) \ - #exam-info.number \ - #exam-info.content - ], - ), - line(length: 100%, stroke: 1pt + gray), - if show-student-data in (true, "first-page", "odd-pages") { - __g-student-data() - } - ) - ) - )] - } - else if calc.rem-euclid(__page-number, 2) == 1 { - grid( - columns: (auto, 1fr, auto), - gutter:0.3em, - align(left + top)[ - #if type(school) == "dictionary" [ - #school.at("name", default : none) \ - ] - #exam-info.academic-period \ - #exam-info.academic-level - ], - align(center + top)[ - // #exam-info.number #exam-info.content \ - ], - align(right + top)[ - #exam-info.at("academic-subject", default: none) \ - #exam-info.number \ - #exam-info.content - ] - ) - line(length: 100%, stroke: 1pt + gray) - if show-student-data == "odd-pages" { - __g-student-data(show-line-two: false) - } - } - else { - grid( - columns: (auto, 1fr, auto), - gutter:0.3em, - align(left + top)[ - #if type(school) == "dictionary" [ - #school.at("name", default : none) \ - ] - #exam-info.academic-period \ - #exam-info.academic-level - ], - align(center + top)[ - // #exam-info.number #exam-info.content \ - ], - align(right + top)[ - #exam-info.at("academic-subject", default: none) \ - #exam-info.number \ - #exam-info.content \ - ] - ) - line(length: 100%, stroke: 1pt + gray) - } + let __page-number = counter(page).at(loc).first() + + __show-header( + page-number: __page-number, + school: school, + exam-info: exam-info, + show-student-data: show-student-data) + + // if (__page-number==1) { + // align(right)[#box( + // width:108%, + // grid( + // columns: (auto, auto), + // gutter:0.7em, + // align(left + top)[ + // #if(type(school) == "dictionary") { + // if(school.at("logo", default : none) != none) { + // set image(height:2.5cm, width: 2.7cm, fit:"contain") + // if(type(school.logo) == "content") { + // school.logo + // } + // else if(type(school.logo) == "bytes") { + // image.decode(school.logo, height:2.5cm, fit:"contain") + // } + // else { + // assert(type(school.logo) in (none, "content", "bytes") , message: "school.logo be of type content or bytes.") + // } + // } + // } + // ], + // grid( + // rows: (auto, auto, auto), + // gutter:1em, + // grid( + // columns: (auto, 1fr, auto), + // align(left + top)[ + // #if(type(school) == "dictionary") [ + // #school.at("name", default : none) \ + // ] + // #exam-info.academic-period \ + // #exam-info.academic-level + // ], + // align(center + top)[ + // // #exam-info.number #exam-info.content \ + // ], + // align(right + top)[ + // #exam-info.at("academic-subject", default: none) \ + // #exam-info.number \ + // #exam-info.content + // ], + // ), + // line(length: 100%, stroke: 1pt + gray), + // [22222222222222], + // if show-student-data in (true, "first-page", "odd-pages") { + // __g-student-data() + // } + // ) + // ) + // )] + // } + // else if calc.rem-euclid(__page-number, 2) == 1 { + // grid( + // columns: (auto, 1fr, auto), + // gutter:0.3em, + // align(left + top)[ + // #if type(school) == "dictionary" [ + // #school.at("name", default : none) \ + // ] + // #exam-info.academic-period \ + // #exam-info.academic-level + // ], + // align(center + top)[ + // // #exam-info.number #exam-info.content \ + // ], + // align(right + top)[ + // #exam-info.at("academic-subject", default: none) \ + // #exam-info.number \ + // #exam-info.content + // ] + // ) + // [11111111111111111] + // line(length: 100%, stroke: 1pt + gray) + // if show-student-data == "odd-pages" { + // __g-student-data(show-line-two: false) + // } + // } + // else { + // grid( + // columns: (auto, 1fr, auto), + // gutter:0.3em, + // align(left + top)[ + // #if type(school) == "dictionary" [ + // #school.at("name", default : none) \ + // ] + // #exam-info.academic-period \ + // #exam-info.academic-level + // ], + // align(center + top)[ + // // #exam-info.number #exam-info.content \ + // ], + // align(right + top)[ + // #exam-info.at("academic-subject", default: none) \ + // #exam-info.number \ + // #exam-info.content \ + // ] + // ) + // line(length: 100%, stroke: 1pt + gray) + // } } ), diff --git a/test/student-data/test-001.typ b/test/student-data/test-001-first-page.typ similarity index 52% rename from test/student-data/test-001.typ rename to test/student-data/test-001-first-page.typ index ff95d99..faa6a60 100644 --- a/test/student-data/test-001.typ +++ b/test/student-data/test-001-first-page.typ @@ -5,3 +5,10 @@ show-grade-table: false, ) +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() diff --git a/test/student-data/test-002.typ b/test/student-data/test-002-odd-pages.typ similarity index 52% rename from test/student-data/test-002.typ rename to test/student-data/test-002-odd-pages.typ index f03f005..cf76950 100644 --- a/test/student-data/test-002.typ +++ b/test/student-data/test-002-odd-pages.typ @@ -4,3 +4,11 @@ show-student-data: "odd-pages", show-grade-table: false, ) + +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() \ No newline at end of file diff --git a/test/student-data/test-003.typ b/test/student-data/test-003.typ new file mode 100644 index 0000000..cf76950 --- /dev/null +++ b/test/student-data/test-003.typ @@ -0,0 +1,14 @@ +#import "../../src/lib.typ": * + +#show: g-exam.with( + show-student-data: "odd-pages", + show-grade-table: false, +) + +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() +#pagebreak() \ No newline at end of file