80 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Typst
		
	
	
	
	
	
			
		
		
	
	
			80 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Typst
		
	
	
	
	
	
 | 
						|
 | 
						|
#let context_step(key) = context {
 | 
						|
  let lvl = query(selector(heading).before(here())).at(-1).level+1;
 | 
						|
  counter(key).step(level: lvl)
 | 
						|
}
 | 
						|
 | 
						|
#let laboratoire(course: "Course Name", title: "Course title", doc) = {
 | 
						|
  set page(
 | 
						|
    header: [#course - Labo X - #title],
 | 
						|
    footer: [],
 | 
						|
    numbering: "1 / 1"
 | 
						|
  )
 | 
						|
 | 
						|
  set heading(numbering: "1.1")
 | 
						|
 | 
						|
  show heading: h => { 
 | 
						|
    let fresh = counter(heading).get(); 
 | 
						|
    counter("manipulation").update(fresh)
 | 
						|
    counter("question").update(fresh)
 | 
						|
    h
 | 
						|
  }
 | 
						|
 | 
						|
  doc
 | 
						|
}
 | 
						|
 | 
						|
#let pretty_block(color, title, x) = { 
 | 
						|
 | 
						|
  let edge = color;
 | 
						|
 | 
						|
  block(radius: (top: 3pt), 
 | 
						|
        inset: 4pt, 
 | 
						|
        stroke: 1pt + edge, 
 | 
						|
        fill: color.lighten(50%),
 | 
						|
        width: 100%,
 | 
						|
        below: 0pt,
 | 
						|
        text(weight: "bold", title))
 | 
						|
        
 | 
						|
  block(radius: (bottom: 3pt), 
 | 
						|
        inset: 7pt,
 | 
						|
        stroke: 1pt + edge,
 | 
						|
        fill: color.lighten(80%),
 | 
						|
        width: 100%,
 | 
						|
        x)
 | 
						|
  
 | 
						|
}
 | 
						|
 | 
						|
#let operation(x) = { 
 | 
						|
  context_step("manipulation")
 | 
						|
  pretty_block(rgb("#9f82ff"), "Manipulation " + context counter("manipulation").display(), x)
 | 
						|
}
 | 
						|
#let question(q,a) = {
 | 
						|
  context_step("question")
 | 
						|
  pretty_block(green, "Question " + context counter("question").display("1.1"), q)
 | 
						|
  pretty_block(red, "Réponse " + context counter("question").display("1.1"), a)
 | 
						|
 | 
						|
}
 | 
						|
 | 
						|
#show: laboratoire
 | 
						|
 | 
						|
= Section
 | 
						|
 | 
						|
#operation[Commencez ici]
 | 
						|
 | 
						|
bla bla
 | 
						|
 | 
						|
== Sous-section
 | 
						|
 | 
						|
bli bli
 | 
						|
 | 
						|
#operation[ Une manipulation à effectuer ]
 | 
						|
 | 
						|
#question[ Quelle est la réponse ? ][asd]
 | 
						|
 | 
						|
= Autre sous-section
 | 
						|
 | 
						|
blu blu
 | 
						|
 | 
						|
#question[xxxx][yyyyyy]
 |