Align PDF sidebar chip and chrome with Typst layout.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -174,13 +174,15 @@ function Meta(meta)
|
||||
</div>
|
||||
]], logo_html, company, subtitle_html, title)
|
||||
|
||||
-- Rotated sidebar labels; page chip comes from print.css @page @bottom-left.
|
||||
-- Rotated sidebar labels (title then destinations, matching typst grid columns).
|
||||
-- .chip-gap extends the rule to the @bottom-left page chip (persian ۱/N).
|
||||
local sidebar = string.format([[
|
||||
<div class="print-sidebar print-only" aria-hidden="true">
|
||||
<div class="seg">%s</div>
|
||||
<div class="seg">%s</div>
|
||||
<div class="chip-gap" aria-hidden="true"></div>
|
||||
</div>
|
||||
]], destinations, title)
|
||||
]], title, destinations)
|
||||
|
||||
local running = string.format([[
|
||||
<div class="print-running-header print-only" aria-hidden="true">
|
||||
|
||||
@@ -37,21 +37,20 @@
|
||||
|
||||
@page {
|
||||
size: A4;
|
||||
/* Extra left margin for rotated sidebar; bottom-left box = typst page chip */
|
||||
margin: 2.5cm 2cm 2.5cm 2.8cm;
|
||||
/* Match typst-templates: 2cm sides, 2.5cm top/bottom */
|
||||
margin: 2.5cm 2cm 2.5cm 2cm;
|
||||
@bottom-center {
|
||||
content: counter(page);
|
||||
font-family: "IRNazanin", sans-serif;
|
||||
font-size: 11pt;
|
||||
content: none;
|
||||
}
|
||||
@top-center {
|
||||
content: element(report-header);
|
||||
width: 100%;
|
||||
}
|
||||
/* WeasyPrint only updates counter(page) reliably in @page margin boxes
|
||||
(not inside position:fixed). Place the black n/N chip at bottom-left. */
|
||||
/* Page chip: counters only update in @page margin boxes (not position:fixed).
|
||||
Rotate the whole ۱/N string like typst's -90deg sidebar grid.cell
|
||||
(writing-mode: sideways-lr leaves numerals horizontal in WeasyPrint). */
|
||||
@bottom-left {
|
||||
content: counter(page) " / " counter(pages);
|
||||
content: counter(page, persian) "/" counter(pages, persian);
|
||||
font-family: "IRZar", "IRNazanin", sans-serif;
|
||||
font-size: 11pt;
|
||||
color: #fff;
|
||||
@@ -61,8 +60,11 @@
|
||||
height: 20pt;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
margin-left: -1.6cm;
|
||||
/* Align chip's content-facing (right) edge with the sidebar rule. */
|
||||
margin-left: -1.66cm;
|
||||
margin-bottom: 0.35cm;
|
||||
direction: ltr;
|
||||
transform: rotate(-90deg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,11 +75,16 @@
|
||||
}
|
||||
|
||||
@media print {
|
||||
/* Keep html LTR so position:fixed + left/translateX for the sidebar use a
|
||||
sane containing block. WeasyPrint with html{direction:rtl} shifts fixed
|
||||
boxes far right and they clip before reaching the typst left-edge band.
|
||||
Document content stays RTL on body. */
|
||||
html {
|
||||
direction: rtl;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
body {
|
||||
direction: rtl;
|
||||
font-family: "IRNazanin", sans-serif;
|
||||
font-size: 13pt;
|
||||
line-height: 1.2;
|
||||
@@ -139,17 +146,23 @@ nav.toc-active,
|
||||
}
|
||||
|
||||
/* ===== Left rotated sidebar (every page) ===== */
|
||||
/* Mirrors typst product_test_template / travel-report-template:
|
||||
rotate(-90deg) grid with columns ~(30%, 30%) + page chip in @bottom-left.
|
||||
Negative `left` is clipped by WeasyPrint; use translateX into the margin instead. */
|
||||
.print-sidebar {
|
||||
position: fixed;
|
||||
left: 0.25cm;
|
||||
/* Leave room at the bottom for the @page bottom-left page chip */
|
||||
bottom: 3.4cm;
|
||||
width: 16.5cm;
|
||||
left: 0;
|
||||
/* Keep >= 0 — negative bottom clips the rotated sidebar in WeasyPrint */
|
||||
bottom: 0.05cm;
|
||||
|
||||
/* Labels + chip-gap (~typst place dy:73% band through page chip) */
|
||||
width: 11.5cm;
|
||||
height: 20pt;
|
||||
transform-origin: left bottom;
|
||||
transform: rotate(-90deg);
|
||||
/* Pull into left margin (negative left is clipped by WeasyPrint) */
|
||||
transform: translateX(-0.75cm) rotate(-90deg);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-direction: row-reverse;
|
||||
align-items: stretch;
|
||||
font-family: "IRZar", "IRNazanin", sans-serif;
|
||||
font-size: 13pt;
|
||||
@@ -158,15 +171,22 @@ nav.toc-active,
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
/* Extends the sidebar rule toward the @bottom-left page chip */
|
||||
.print-sidebar .chip-gap {
|
||||
flex: 0 0 28pt;
|
||||
}
|
||||
|
||||
.print-sidebar .seg {
|
||||
/* typst columns: 30% / 30% of the label band */
|
||||
flex: 1 1 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
/* typst: #h(1fr) text #h(5fr) — bias text toward the rule */
|
||||
justify-content: flex-start;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding: 0 6pt;
|
||||
padding: 0 1pt 0 4pt;
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
@@ -184,6 +204,8 @@ nav.toc-active,
|
||||
align-items: flex-start;
|
||||
width: 100%;
|
||||
margin: 0 0 16pt 0;
|
||||
padding-bottom: 10pt;
|
||||
border-bottom: 1pt solid black;
|
||||
direction: ltr;
|
||||
}
|
||||
|
||||
@@ -263,20 +285,13 @@ h1, h2, h3, h4 {
|
||||
page-break-after: avoid;
|
||||
}
|
||||
|
||||
/* Level-1/2 headings get a full-width rule above (typst show heading) */
|
||||
h1, h2 {
|
||||
font-size: 14pt;
|
||||
margin: 16pt 0 10pt 0;
|
||||
padding-top: 8pt;
|
||||
border-top: 1pt solid black;
|
||||
}
|
||||
|
||||
/* First body heading after Quarto title header: no rule (typst skips at top) */
|
||||
#title-block-header + h1,
|
||||
.print-title-block + h1,
|
||||
.print-travel-meta + h1 {
|
||||
border-top: none !important;
|
||||
padding-top: 0 !important;
|
||||
margin-top: 8pt;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user