Repository navigation
How to specify relative font sizes? #2182
|
Looking at the code for the verbatim environment, it sets the font size to the current size - 3 (pt?). I was not able to work out how to write that in the declarative syntax. The manual mentions that you can write things in terms of the page height or width. |
Replies: 2 comments 8 replies
It still does? This is likely wrong, there's no reason for using a "hard-coded" 3pt smaller font, not depending on what was the original size. ^^ |
|
The easiest ways is to use relative units. For example the Relative sizes are typically not specified as with an absolute value offset from a relative size. You could do that, but you'd probably need to make a small wrapper function of your own to accomplish it: SILE.registerCommand("three-smaller", function (options, content)
options.size = SILE.types.measurement("1em"):absolute() - SILE.types.measurement("3pt")
SILE.call("font", options, content)
end)Then in your content, you could use |
So now that SILE 0.15.10 is available, we should be able to answer the question fully.
Relative font size can be expressed in a font-relative unit.
1em= the current font size1en=0.5em)1ex= the height of an "x" in the current font.The em is the most used e.g. for bigger title headings, smaller block quotes, etc.
So if you had, say, a current font at 10pt, and then use
\font[size=0.9em]{smaller}, the "smaller text" will now 90% smaller, hence at 9pt.The ex unit expresses a size relative to the x-height and is also sometimes used, mostly for scaling and raising characters in the same font. A poor's man superscript 1 could for instance be
\raise[height=0.7ex]{\font[size=1.5ex]{1}}…