#Center items using stack
124 messages ยท Page 1 of 1 (latest)
but i want the item with items above and down to be centered with the + and the rest
?r `
#let item(i: 1, p: 0) = {
if(p == 0) {
stack(
dir: ttb,
spacing: 0.5em,
text(0.5em)[i=#i],
[i],
)
} else {
stack(
dir: ttb,
spacing: 0.5em,
text(0.5em)[i=#i],
[i],
text(0.5em)[p=#p]
)
}
}
#align(horizon)[
#box[#item(i: 1, p: 12)] + 1
]
`
you can use the baseline parameter for box
though to be honest i'd just use math mode if possible
?r $ limits(i)_(p=12)^(i = 1) + 1 $
Why the limits function?
remove it to see ๐
I see
I thought limits was for that, limits, didn't think it could be used like this
Thanks!
yeah I think the idea is that it "behaves like a limit" or something but idk
unfortunately the mathemagicians have outsmarted me here
im gonna ping the master mathemagician just in case
@crisp kernel
no prob
also, why does this block not render the results themselves?
?r ```typst
#let item = {
range(2).map(n => {
let p = n+1
$limits(n)_(p=p)^(p=n)$
})
}
$item$
cuz you're not displaying the results
you're displaying an array
you probably meant to .join() after the map
which does like array.at(0) + array.at(1) + ... + array.last()
alternatively you can write
for n in range(2) {
let p = n + 1
$ something $
}
and it will automatically join all of the results
i mean
if you dont enter code mode it will display that literally in your text
but you can just write #for
and that should be enough
also, this does output like this
how can i replace the inner n with the actual number?
#
the only solution i found is using a #box[#n]
?r
#let x = 5
$ #x + 10 $
?r `
#let item = {
range(2).map(n => {
let p = n+1
$limits(#n)_(p=p)^(p=n)$
}).join("+")
}
#item
`
An error occurred:
Error: expected content, found integer
โญโ[/main.typ:12:14]
โ
12 โ $limits(#n)_(p=p)^(p=n)$
โ โ
โ
โโโโโฏ
this is the error i get
yeah limits is picky about what it gets
you can cast it to content with #[#n]
or
you can do something like #math.limits(n)
but yeah
nice, welcome ๐
what's the difference between doing $math_here$ and $ math here $?
(and why does it not center on screen when combined with a #block?)
Limits are also used in the sense of "limite of an integral" or "limits of a series", which is what it means here. The corresponding macro in LaTeX is also \limits
The first is inline math ($ $ or \( \) in LaTeX), the second is display math (\[ \] in LaTeX or $$ $$ in plain TeX)
Block by itself doesn't align anything
i mean, when i do $ <math here> $ it centers itself horizontally, but when i do #block[$ <math here> $] it doesn't
Because it's now centered with respect to the block you put around it
oh
i've noticed if writing math within a block and want to break the line, the new math gets centered again, do i need to have a block per line or is there any other way?
?r ```typst
#block[$ F(x) = sum_(x=x)^s "long expression"
= "more code"
$]
it centers at the new line again
Like I said, it was always centered, just in relation to the block
Why are you putting it in a block in the first place?
I want the sums to show like in here
if not they show a little different
?r $sum_(x = x)^y$\ #block[$ sum_(x=x)^y $]
i want it to show like the one in the bottom
there's an xy problem here
what you actually want is left-aligned block math
?render ```
#show math.equation: set align(left)
$
F(x) = sum_(x=x)^s "long expression"
= "more code"
$
didn't know i could do this
If instead you actually want inline math with display style limits, you can use limits(sum)instead of simply sum
i'm not really familiar with show instructions
?render ```
$sum_(n=0)^oo 1/(n^2)$ vs $limits(sum)_(n=0)^oo 1/(n^2)$
though it's not recommended to actually use that inline, since it'll be so tall that it'll affect line spacing
if you truly want inline math that looks like block math
this was perfect
also, doesn't #show instructions give parameters? like #show: doc => ...
#show x: set y is syntactic sugar for #show x: it => {set y; it} iirc
thats cool ngl
thanks
ok, now inline equations get formatted into their own lines ._.
is there a way to have block equations aligned to the left and inline equations like normal?
?r ```typst
#show math.equation: set align(left)
This is an $F(x) = "equation"$ inlined
?r ```typst
#show math.equation.where(block: true): set align(left)
This is an $F(x) = "equation"$ inlined
This is block $ 1 + 1 $
My bad