|
51 | 51 | #import "@preview/cetz:0.4.2": canvas, draw |
52 | 52 | #import "@preview/ctheorems:1.1.3": thmbox, thmplain, thmproof, thmrules |
53 | 53 | #import "lib.typ": g-node, g-edge, petersen-graph, house-graph, octahedral-graph, draw-grid-graph, draw-triangular-graph, graph-colors, selem, sregion, draw-node-highlight, draw-edge-highlight, draw-node-colors, sregion-selected, sregion-dimmed, gate-and, gate-or, gate-xor |
| 54 | +#import "web.typ": export-details, detail-key, detail-article |
54 | 55 |
|
55 | 56 | #set page( |
56 | 57 | paper: "a4", |
|
64 | 65 |
|
65 | 66 | // Set up theorem environments with ctheorems |
66 | 67 | #show: thmrules.with(qed-symbol: $square$) |
| 68 | +#show math.equation: it => context { |
| 69 | + if export-details and target() == "html" { |
| 70 | + html.elem(if it.block { "div" } else { "span" }, attrs: (class: "typst-math"), html.frame(it)) |
| 71 | + } else { it } |
| 72 | +} |
| 73 | +#show figure: it => context { |
| 74 | + if export-details and target() == "html" { |
| 75 | + html.elem("figure")[ |
| 76 | + #html.frame(it.body) |
| 77 | + #if it.caption != none { html.elem("figcaption", it.caption.body) } |
| 78 | + ] |
| 79 | + } else { it } |
| 80 | +} |
| 81 | +#show block: it => context { |
| 82 | + if export-details and target() == "html" { |
| 83 | + if it.height != auto { html.frame(it) } else { html.elem("div", it.body) } |
| 84 | + } else { it } |
| 85 | +} |
| 86 | +#show align: it => context { |
| 87 | + if export-details and target() == "html" { it.body } else { it } |
| 88 | +} |
| 89 | +#show pad: it => context { |
| 90 | + if export-details and target() == "html" { it.body } else { it } |
| 91 | +} |
| 92 | +#show grid: it => context { |
| 93 | + if export-details and target() == "html" { html.frame(it) } else { it } |
| 94 | +} |
| 95 | +#show stack: it => context { |
| 96 | + if export-details and target() == "html" { html.frame(it) } else { it } |
| 97 | +} |
67 | 98 |
|
68 | 99 | // === Example JSON helpers === |
69 | 100 | // Load the generated canonical example database. |
|
501 | 532 |
|
502 | 533 | // Render a block of pred CLI commands for reproducibility |
503 | 534 | #let pred-commands(..cmds) = { |
| 535 | + if export-details { return raw(cmds.pos().join("\n"), block: true) } |
504 | 536 | block( |
505 | 537 | width: 100%, |
506 | 538 | fill: luma(245), |
|
531 | 563 | ) |
532 | 564 |
|
533 | 565 | // Problem definition wrapper: auto-adds schema, complexity, reductions list, and label |
534 | | -#let problem-def(name, def, body) = { |
535 | | - let lbl = label("def:" + name) |
| 566 | +#show ref: it => context { |
| 567 | + let name = str(it.target) |
| 568 | + if export-details and target() == "html" and name.starts-with("def:") { |
| 569 | + link(it.target, display-name.at(name.slice(4))) |
| 570 | + } else { it } |
| 571 | +} |
| 572 | +#let problem-def(name, def, body, variant: none) = { |
| 573 | + if export-details { |
| 574 | + return detail-article("problem:" + detail-key(name, variant))[ |
| 575 | + #html.elem("h3")[Definition] |
| 576 | + #def |
| 577 | + #html.elem("h3")[Background and example] |
| 578 | + #body |
| 579 | + ] |
| 580 | + } |
| 581 | + let lbl = label("def:" + detail-key(name, variant)) |
536 | 582 | let title = display-name.at(name) |
537 | 583 | [#definition(title)[ |
538 | 584 | #def |
|
586 | 632 | example-target-variant: none, |
587 | 633 | example-caption: none, |
588 | 634 | extra: none, |
| 635 | + source-variant: none, |
| 636 | + target-variant: none, |
589 | 637 | theorem-body, proof-body, |
590 | 638 | ) = { |
| 639 | + if export-details { |
| 640 | + return detail-article("rule:" + detail-key(source, source-variant) + "->" + detail-key(target, target-variant))[ |
| 641 | + #html.elem("h3")[Reduction] |
| 642 | + #theorem-body |
| 643 | + #html.elem("h3")[Proof] |
| 644 | + #proof-body |
| 645 | + #if example { |
| 646 | + html.elem("h3")[Example] |
| 647 | + if example-caption != none { strong(example-caption) } |
| 648 | + extra |
| 649 | + } |
| 650 | + ] |
| 651 | + } |
591 | 652 | let arrow = sym.arrow.r |
592 | 653 | let edge = find-edge(source, target) |
593 | 654 | let src-disp = if edge != none { variant-display(graph-data.nodes.at(edge.source)) } |
|
597 | 658 | let src-lbl = label("def:" + source) |
598 | 659 | let tgt-lbl = label("def:" + target) |
599 | 660 | let parameters = if edge != none and edge.parameters.len() > 0 { edge.parameters } else { none } |
600 | | - let thm-lbl = label("thm:" + source + "-to-" + target) |
| 661 | + let thm-lbl = label("thm:" + detail-key(source, source-variant) + "-to-" + detail-key(target, target-variant)) |
601 | 662 | covered-rules.update(old => old + ((source, target),)) |
602 | 663 |
|
603 | 664 | [ |
@@ -19589,4 +19650,8 @@ The following table shows concrete target-variable counts for example instances, |
19589 | 19650 | ] |
19590 | 19651 |
|
19591 | 19652 | #pagebreak() |
19592 | | -#bibliography("references.bib", style: "ieee") |
| 19653 | +#if export-details { |
| 19654 | + detail-article("references")[#bibliography("references.bib", style: "ieee")] |
| 19655 | +} else { |
| 19656 | + bibliography("references.bib", style: "ieee") |
| 19657 | +} |
0 commit comments