box
元素
元素函数可以通过 set 和 show 规则进行样式自定义。
An inline-level container that sizes content.
All elements except inline math, text, and boxes are block-level and cannot occur inside of a paragraph. The box function can be used to integrate such elements into a paragraph. Boxes take the size of their contents by default but can also be sized explicitly.
Example
Refer to the docs
#box(
height: 9pt,
image("docs.svg")
)
for more information.
参数
参数是函数的输入,它们在函数名称后面的括号中传入。
width
The width of the box.
Boxes can have fractional widths, as the example below demonstrates.
Note: Currently, only boxes and only their widths might be fractionally sized within paragraphs. Support for fractionally sized images, shapes, and more might be added in the future.
默认:auto
查看示例
Line in #box(width: 1fr, line(length: 100%)) between.
height
The height of the box.
默认:auto
baseline
An amount to shift the box's baseline by.
默认:0pt
查看示例
Image: #box(baseline: 40%, image("tiger.jpg", width: 2cm)).
fill
The box's background color. See the rectangle's documentation for more details.
默认:none
stroke
The box's border color. See the rectangle's documentation for more details.
默认:none
radius
How much to round the box's corners. See the rectangle's documentation for more details.
默认:0pt
inset
How much to pad the box's content.
Note: When the box contains text, its exact size depends on the current text edges.
默认:0pt
查看示例
#rect(inset: 0pt)[Tight]
outset
How much to expand the box's size without affecting the layout.
This is useful to prevent padding from affecting line layout. For a generalized version of the example below, see the documentation for the raw text's block parameter.
默认:0pt
查看示例
An inline
#box(
fill: luma(235),
inset: (x: 3pt, y: 0pt),
outset: (y: 3pt),
radius: 2pt,
)[rectangle].
clip
Whether to clip the content inside the box.
默认:false
body
The contents of the box.
默认:none