【问题标题】:In InDesign, is there a way to bold a whole word that has one bold character?在 InDesign 中,有没有办法将具有一个粗体字符的整个单词加粗?
【发布时间】:2022-01-12 04:26:58
【问题描述】:

我正在处理 InDesign 中的索引。一些页码以粗体显示,另一些以斜体或常规显示。在编辑过程中,一些粗体页码的第一个数字不知何故被改变了。我已经弄清楚如何通过为粗体数字着色并使用 GREP 搜索粗体字 (\b\w+\b) 重新着色正确的页码来突出显示这些页码。我想不通的是如何选择只有一些数字的“坏”页码并使整个“单词”加粗。有任何想法吗?不必手动修复它们会很好。

【问题讨论】:

  • 您解决问题了吗?您是否尝试过建议的解决方案?您能提供反馈吗?
  • 由于没有反馈而被否决。

标签: adobe-indesign grep-indesign


【解决方案1】:

我刚刚在一个文档上尝试了这个,并添加了一些只是部分粗体的数字。

我能够通过使用 (\b\d+\b) 仅搜索数字,将所有更改为 $1 来修复它。我将查找格式留空并将格式更改为常规字体。这将所有数字更改为常规数字,没有混合粗体和常规。

之后,您可以再次运行相同的查找和替换,但将格式切换为粗体。这会将所有数字更改为完全粗体。

【讨论】:

    【解决方案2】:

    这在很大程度上取决于您拥有的文本。如果只是需要更改的第一个数字,如果您不使用字符样式,如果您的正文中没有数字,如果您使用的字体具有样式的通用名称,如果...有实际上,有很多“如果”。我建议分享您的文件样本 (IDML)。

    所以,这里是可以完成这项工作的脚本(如果所有这些“如果”都是真的):

    var doc = app.activeDocument;
    var styles = doc.characterStyles;
    
    
    // STEP 1 -- apply style1 (regular) to all regular numbers \d\d+
    var style1 = styles.add();
    style1.name = 'digits_regular';
    style1.fontStyle = 'Regular';
    
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat  = '\\b\\d\\d+'; // two or more digits
    app.findGrepPreferences.fontStyle = 'Regular';
    
    app.changeGrepPreferences.changeTo = '$0';
    app.changeGrepPreferences.appliedCharacterStyle = style1;
    
    doc.changeGrep();
    
    
    // STEP 2 -- apply style2 (italic) to all italic numbers \d\d+
    var style2 = styles.add();
    style2.name = 'digits_italic';
    style2.fontStyle = 'Italic';
    
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat  = '\\b\\d\\d+';
    app.findGrepPreferences.fontStyle = 'Italic';
    
    app.changeGrepPreferences.changeTo = '$0';
    app.changeGrepPreferences.appliedCharacterStyle = style2;
    
    doc.changeGrep();
    
    
    // STEP 3 -- apply style3 (bold) to all unstyled numbers
    var style3 = styles.add();
    style3.name = 'digits_bold';
    style3.fontStyle = 'Bold';
    
    app.findGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.findWhat = '\\b\\d\\d+';
    app.findGrepPreferences.appliedCharacterStyle = styles[0]; // syle '[None]'
    
    app.changeGrepPreferences.changeTo = '$0';
    app.changeGrepPreferences.appliedCharacterStyle = style3;
    
    doc.changeGrep();
    
    
    // clean prefs
    app.findGrepPreferences = NothingEnum.nothing;
    

    输入:

    结果:

    然后您可以删除不需要的字符样式。但我建议使用样式。正是在这种情况下,它们让生活变得更轻松。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-28
      • 1970-01-01
      • 1970-01-01
      • 2020-08-30
      • 1970-01-01
      相关资源
      最近更新 更多