ludwig
September 20, 2024, 9:45pm
1
I am trying to write a function which among other things should turn content which is
display/inline sized to script size and
script sized to sscript size.
(Similar how subscript etc. behave.)
My own attempt was something like:
#let returnsizestyle = context {
measure($M$).width
// comparison to measure($script(M)$).width
}
$ display(returnsizestyle) inline(returnsizestyle) script(returnsizestyle) sscript(returnsizestyle) $
Do you have some idea on how to achieve this?
Enivex
September 21, 2024, 1:40pm
2
I do not believe this is possible at the moment
Andrew
September 21, 2024, 4:49pm
3
I think the key issue here is that any of those functions aren’t elements and therefore can’t be handled separately via #show func-name
. I made an example that shows current size of an element:
#set text(12pt)
#context text.size
#show heading: set text(13pt)
#show heading: it => it + repr(text.size)
#show raw: set text(14pt)
#show raw: it => it + " " + repr(text.size)
#show math.equation: set text(15pt)
#show math.equation: it => it + " " + repr(text.size)
#show "x": it => it + " (" + repr(text.size) + ")"
x
---
= x
---
`x`
---
$x$
I also played a bit with the equation functions:
#context measure($display(x)$).width
#context measure($inline(x)$).width
#context measure($script(x)$).width
#context measure($sscript(x)$).width
#let s = 11pt
#context measure(text(s, $x$)).width
#text(s, $x$)
#(s.pt() / 6.29)
#let s = 8.72pt
#context measure(text(s, $x$)).width
#text(s, $x$)
#(s.pt() / 4.99)
#let s = 7.62pt
#context measure(text(s, $x$)).width
#text(s, $x$)
#(s.pt() / 4.36)
#show math.equation: it => repr(it.body)
$display(x)
inline(x)
script(x)
sscript(x)
$
I think if they were to be elements, then it could be done something like this:
#show math.display: set text(8.72pt)
#show math.inline: set text(8.72pt)
#show math.script: set text(7.62pt)
Since you can’t get directly the text.size
for any element (I don’t think so) like heading.text.size
, this means you can’t do:
#show math.display: it => text(math.script.text.size, it)
#show math.inline: it => text(math.script.text.size, it)
#show math.script: it => text(math.sscript.text.size, it)