You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在customUI.xml中为Word功能区按钮标签添加换行?

Word功能区按钮标签两行显示的解决方法

要让「Add/Edit Citation」按钮标签显示为两行,你不能用普通的<br>、\n这类字符,Office Ribbon的customUI只识别XML标准的Unicode换行实体&#10;,具体操作如下:

关键修改步骤

  • 将按钮的label属性值中的空格替换为&#10;,也就是把label="Add/Edit Citation"改成label="Add/Edit&#10;Citation"
  • 确保按钮保留size="large"属性,只有大尺寸按钮支持多行标签显示

修改后的完整customUI.xml代码

<?xml version="1.0"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
  <ribbon>
    <tabs>
      <tab id="ZoteroTab" getLabel="ZoteroRibbon.ZoteroTabLabel" insertBeforeMso="TabAddIns">
        <group id="ZoteroGroup" image="zoteroz16" label="Zotero">
          <!-- 修改了label属性,添加换行实体 -->
          <button id="InsertZoteroCitationButton" label="Add/Edit&#10;Citation" size="large" image="addEditZoteroCitation" onAction="ZoteroRibbon.ZoteroRibbonAddEditCitation" supertip="Insert a new citation, or edit the citation at the current cursor position"/>
          <button id="InsertZoteroNoteButton" label="Add Note" size="large" image="addZoteroNote" onAction="ZoteroRibbon.ZoteroRibbonAddNote" supertip="Insert a new note at the current cursor position"/>
          <button id="InsertZoteroBibliographyButton" label="Add/Edit Bibliography" size="large" image="addEditZoteroBibliography" onAction="ZoteroRibbon.ZoteroRibbonAddEditBibliography" supertip="Insert a new bibliography, or edit the existing bibliography, at the current cursor position"/>
          <button id="ZoteroSetDocPrefs" label="Document Preferences" image="setZoteroDocPrefs-small" onAction="ZoteroRibbon.ZoteroRibbonSetDocPrefs" supertip="Change the citation style or locale"/>
          <button id="RefreshZotero" label="Refresh" image="RefreshZotero" onAction="ZoteroRibbon.ZoteroRibbonRefresh" supertip="Update all citations to reflect changes"/>
          <button id="ZoteroRemoveCodes" label="Unlink Citations" image="ZoteroRemoveCodes" onAction="ZoteroRibbon.ZoteroRibbonRemoveCodes" supertip="Remove all Zotero field codes and unlink from Zotero library"/>
          <!-- <button id="InsertZoteroCitationButtonSmall" visible="false" label="Add/Edit Citation" image="addEditZoteroCitation-small" onAction="ZoteroRibbon.ZoteroRibbonAddEditCitation" supertip="Insert a new citation, or edit the citation at the current cursor position"/>
        <button id="InsertZoteroBibliographyButtonSmall" visible="false" label="Add/Edit Bibliography" size="large" image="addEditZoteroBibliography-small" onAction="ZoteroRibbon.ZoteroRibbonAddEditBibliography" supertip="Insert a new bibliography, or edit the existing bibliography, at the current cursor position"/>
          <button id="ZoteroSetDocPrefsLarge" visible="false" label="Document Preferences" size="large" image="setZoteroDocPrefs" onAction="ZoteroRibbon.ZoteroRibbonSetDocPrefs" supertip="Change the citation style or locale"/> -->
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

额外注意事项

  • 保存XML文件时必须选择UTF-8编码,防止换行实体被错误解析
  • 修改后重启Word才能生效,如果仍不显示多行,检查是否有其他自定义UI代码冲突

内容的提问来源于stack exchange,提问作者Minyi Han

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 13:10:33