Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Theorem and picture side by side #23

Open
fagu opened this issue Apr 16, 2024 · 2 comments
Open

Theorem and picture side by side #23

fagu opened this issue Apr 16, 2024 · 2 comments

Comments

@fagu
Copy link

fagu commented Apr 16, 2024

I would like to display text and a picture side by side inside the theorem's box, like this:
test2-wanted
Is there an easy way to achieve this?
The following code produces an unnecessary line break after "Theorem 0.1":

#import "@preview/ctheorems:1.1.2": *
#show: thmrules
#set page(width: 11cm, height: 4cm, margin: 0pt)
#let theorem = thmbox("theorem", "Theorem", fill: blue.lighten(90%))

#theorem[
  #grid(columns: (1fr, auto), gutter: 1em,
    lorem(20),
    box(stroke: 1pt+black, width: 2cm, height: 2cm)[#align(center + horizon)[Picture]]
  )
]

test2
(Same if you use the wrap-it package instead of directly using grid.)
What do you think about adding a parameter blockfmt: x => x to boxfmt that transforms the entire block as blockfmt([#title#name#separator#body])? One could then use:

#import "ctheorems.typ": *
#show: thmrules
#set page(width: 11cm, height: 3cm, margin: 0pt)
#let theorem = thmbox("theorem", "Theorem", fill: blue.lighten(90%))

#theorem(
  blockfmt: it =>
    grid(columns: (1fr, auto), gutter: 1em,
      it,
      box(stroke: 1pt+black, width: 2cm, height: 2cm)[#align(center + horizon)[Picture]]
    )
)[
  #lorem(20)
]
@sahasatvik
Copy link
Owner

I like the idea of a blockfmt, will try and give that flexibility in v2.0.0.

The best solution I can offer at the moment is putting the grid around the theorem.

#import "@preview/ctheorems:1.1.2": *
#show: thmrules
#set page(width: 11cm, height: auto, margin: 0.5cm)

#let theorem = thmbox("theorem", "Theorem", fill: blue.lighten(90%))

#theorem[
  #lorem(15)
]

#let theorem-2col(..args, first, second) = {
  let theorem = thmbox("theorem", "Theorem", padding: (top: 0em, bottom: 0em), inset: 0em)
  block(fill: blue.lighten(90%), radius: 0.3em, inset: 1.2em)[
    #grid(columns: (1fr, auto), gutter: 1em, align: horizon)[
      #theorem(..args)[
        #first
      ]
    ][
      #second
    ]
  ]
}

#theorem-2col([Name])[
  #lorem(16)
][
  #box(stroke: 1pt + black, width: 2cm, height: 2cm)[#align(center + horizon)[Picture]]
]

pic

@fagu
Copy link
Author

fagu commented Apr 16, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants