Typst 0.5.0非IEEE风格参考文献首行无缩进问题解决
修复Typst 0.5.0中非IEEE风格参考文献的缩进问题
Typst 0.5.0里,APA等非IEEE参考文献风格默认采用悬挂缩进(首行无缩进、后续行缩进),如果需要实现所有行统一缩进的效果,可以通过自定义参考文献条目渲染逻辑解决:
解决方案代码
#set bibliography( style: "apa", // 替换为你需要的目标风格 entry: e => { paragraph( indent: 1em, // 自定义首行缩进大小,可按需调整 hanging-indent: 0em, // 取消默认的悬挂缩进 content: bibliography.entry(e, style: "apa") // 保留原风格的内容渲染逻辑 ) } ) #bibliography("bib.bib") // 你的bib文件路径
代码说明
- 通过
bibliography的entry参数,重新定义单条参考文献的渲染规则 - 用
paragraph包裹默认风格生成的条目内容,强制覆盖缩进属性:indent: 1em:给首行设置指定大小的缩进hanging-indent: 0em:关闭默认的悬挂缩进,让后续行和首行保持一致缩进
- 修改
style参数的值,即可适配chicago、mla等其他非IEEE风格
原问题场景示例
假设你的原代码是:
#set bibliography(style: "apa") #bibliography("bib.bib")
对应的bib.bib内容:
@article{example1, author = {Smith, John and Doe, Jane}, title = {An Example Article}, journal = {Journal of Examples}, year = {2023}, volume = {10}, pages = {123-145} } @book{example2, author = {Brown, Alice}, title = {A Sample Book}, publisher = {Sample Publisher}, year = {2022}, address = {New York} }
使用修复代码后,所有参考文献条目会呈现首行与后续行统一缩进的格式,符合预期要求。
内容的提问来源于stack exchange,提问作者Refreshing Breeze
相关产品推荐
相关产品推荐

