如何修改CSL代码使作者姓名显示为全大写?
问题:CSL代码添加text-case="uppercase"无法实现作者姓名全大写
我需要修改CSL代码,让参考文献中的作者姓名显示为全大写。但在代码中添加text-case="uppercase"属性后没有任何效果,不过设置font-weight等其他样式属性可以正常生效。
当前使用的CSL代码
<macro name="author"> <names variable="author" font-weight="normal" text-decoration="none" vertical-align="baseline"> <name font-variant="normal" font-weight="normal" delimiter-precedes-last="never" initialize-with=". " name-as-sort-order="all"/> <label form="short" prefix=" (" suffix=")"/> <et-al font-style="italic"/> <substitute> <names variable="editor"/> <names variable="translator"/> <choose> <if type="article-newspaper article-magazine" match="any"> <text variable="container-title" text-case="title" font-style="italic"/> </if> <else> <text macro="title"/> </else> </choose> </substitute> </names> </macro>
现有效果示例
Campbell, J. L., Pedersen, O. K. (2007):The varieties of capitalism and hybrid success, Comparative Political Studies, 40(3), 307–332. doi:10.1177/0010414006286542.
期望效果示例
CAMPBELL, J. L., PEDERSEN, O. K. (2007):The varieties of capitalism and hybrid success, Comparative Political Studies, 40(3), 307–332. doi:10.1177/0010414006286542.
解决方案
在CSL规范中,text-case属性需要直接作用于<name>标签而非外层的<names>容器标签。将text-case="uppercase"添加到<name>元素上即可实现作者姓名全大写,修改后的代码如下:
<macro name="author"> <names variable="author" font-weight="normal" text-decoration="none" vertical-align="baseline"> <name font-variant="normal" font-weight="normal" delimiter-precedes-last="never" initialize-with=". " name-as-sort-order="all" text-case="uppercase"/> <label form="short" prefix=" (" suffix=")"/> <et-al font-style="italic"/> <substitute> <names variable="editor"/> <names variable="translator"/> <choose> <if type="article-newspaper article-magazine" match="any"> <text variable="container-title" text-case="title" font-style="italic"/> </if> <else> <text macro="title"/> </else> </choose> </substitute> </names> </macro>
原因很直接:<names>只是姓名集合的容器,不处理文本格式转换;<name>才是控制单个姓名显示格式的核心元素,所以文本转换属性必须加在这里才能生效。
内容的提问来源于stack exchange,提问作者TGF
相关产品推荐
相关产品推荐

