# add_caption
添加题注
函数库: TyReportGenerator
# 语法
add_caption(obj, caption)
# 说明
add_caption(obj; caption) 在 doc 对象上添加题注。示例
# 示例
添加题注
创建 Word 文档,添加函数列表的表格。
using TyReportGenerator
doc = create_document()
pkg_dir = pkgdir(TyReportGenerator)
headerLabels = ["序号", "函数名", "简介"]
number = [1, 2, 3, 4]
names = ["create_titlepage", "create_tableofcontents", "create_text", "create_paragraph"];
statements = ["创建封面", "创建目录", "创建文本", "创建段落"];
tableData = [number, names, statements]
table = create_table(tableData; style=Dict("style_type" => "简单样式 - 行"))
add_header(table, headerLabels)
在表格上方添加表格题注。查看文档。
caption = create_caption([
create_text("表 "),
create_text("函数列表"; style=Dict("halign" => "center", "style_type" => "题注")),
])
paragraph = create_paragraph([table])
add_caption(paragraph, caption)
add_paragraph(doc, paragraph)
doc_file = joinpath(tempdir(), "Add Caption.docx");
tpl_file = joinpath(pkg_dir, "examples/Resources/文档模板-蓝标.docx");
generate_report(doc, doc_file, tpl_file)
rptview(doc_file)
# 输入参数
obj — paragraph对象paragraph对象
包含在文档中的段落对象(paragraph对象)。
caption — caption对象caption对象
文档中的 caption 对象,存储题注信息。