MathTop

center_string 函数

在文本两侧补入字符,使文本位于指定宽度的中间。

语法

  • Center(text, width)
  • Center(text, width, fill)
  • center_string(text, width, fill)

参数与选项

text文本值,通常写在引号中。
width目标文本宽度;小于当前长度时原样返回。
fill可选的单字符填充文本;省略时使用空格。

示例

  1. 居中文本Center('abc', 8, '-')返回 --abc---。