#Scripting: `showybox`

22 messages · Page 1 of 1 (latest)

mild laurel
#

Hello good people, I've got this showybox here (more can be found in template.typ and ommnibus.typ):

  border-color: white,
  title-color: black,
  body-color: black,
  footer-color: black,
  thickness: (left: 1pt),
  radius: 0pt
  ),
  body-style: (
  color: white
  ),
  footer-style: (
  color: white
  ),
  title-style: (
  color: white,
  weight: "bold",
  ),
  sep: (
  dash: "loosely-dashed"
  ),
    title: [Theorem 2.43 (Dimension of a sum).],
    
  )[If $V_1,V_2$ of a #sbs of a #findem #vsp, then $ dim (V_1 + V_2) = dim V_1 + dim V_2 - dim (V_1 sect V_2). $]```

I don't know how to script this box into one command that also conforms to the section number:

`#thm[#number (in this case 43)][#name (Dimension of a sum)][#content1][#content2]...[#contentn](#footer)`

Could someone help me?
crimson nymph
#

?r

#import "@preview/showybox:2.0.1": showybox
#set heading(numbering: "1.")

= First Section

#let thm(number: 0, name: [], ..contents) = showybox(
  frame: (
    border-color: white,
    title-color: black,
    body-color: black,
    footer-color: black,
    thickness: (left: 1pt),
    radius: 0pt
  ),
  body-style: (
    color: white
  ),
  footer-style: (
    color: white
  ),
  title-style: (
    color: white,
    weight: "bold",
  ),
  sep: (
    dash: "loosely-dashed"
  ),
  title: [Theorem #(context counter(heading).get().at(0)).#number (#name).], 
  ..contents
)


#thm(number: 43, name: [Dimensions of a sum])[
If $V_1,V_2$ of ... then $ dim (V_1 + V_2) = dim V_1 + dim V_2 - dim (V_1 sect V_2). $
][
More content
]
pliant moth
mild laurel
mild laurel
#

Alright folks, one more touch and we're done. Given this fn:

  frame: (
  border-color: silver,
  title-color: silver.lighten(80%),
  footer-color: silver.lighten(90%),
  thickness: (left: 1pt),
  radius: 0pt
  ),
  title-style: (
  color: silver.darken(50%),
  weight: "bold",
  ),
  sep: (
  dash: "loosely-dashed"
  ),
  title: [Exercise #(context counter(heading).get().at(0)).#number (#name).], 
  ..contents
)

Is there a way to make it referable using ref?

#

For the example above, when I give it the tag <exam1>, typing @exam1 should display Exercise 1.

pliant moth
#

Here's a solution using ctheorems: #bot-corner message

mild laurel
# pliant moth Here's a solution using `ctheorems`: https://discord.com/channels/10544437219759...

I modified your code, and here is the result:

  thmenv(
    head,
    base,
    base_level,
    (name, number, body, ..args) => {
      name =  if name != none {[(#name)]} else []
      showybox(
        title: [#head #(context counter(heading).get().at(0)).#number #name],
        frame: (
        border-color: blue,
        title-color: blue.lighten(80%),
        footer-color: blue.lighten(90%),
        thickness: (left: 1pt),
        radius: 0pt
        ),
        title-style: (
        color: blue.darken(50%),
        weight: "bold",
        ),
        sep: (
        dash: "loosely-dashed"
        ),
        ..args.named(),
        body
      )
  }).with(
    supplement: head
  )
}```
#

Problem is that the number doesn't show up:

#example([First], number: [1.1], footer: lorem(20))[
  #lorem(10)
] <first>

This is a reference to @first.```
pliant moth
#

Ah, this appears to be a bug (the reference doesn't work properly if you set the number manually)

#

On my list of fixes for v2.0.0

mild laurel
#

Great. I'll be using this for now, though.

mild laurel
pliant moth
#

Oh I see, the thmenv only treats one (the last?) argument as the body ...

mild laurel
pliant moth
#

Here's a hacky way around: #bot-corner message

mild laurel