• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
10

Need help because of a tricky find & change function

Enthusiast ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Hello!

I have documents where sometimes the word "lD" is wrongly written. It should be replaced with λD (Lambda+subscript D).

 

How do I manage to replace the l in the Symbol Regular font and at the same time lower the D?

 

So far, I could only lower the D in the word "lD" with the help of the Grep search, but I can't figure out how I can replace the l in the other font. Can someone help me, please? Thank you!

 

aniri5j9ox8tw2ln_0-1710236049175.png

 

TOPICS
How to , Scripting , Type

Views

192

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Many fonts apart from Symbol would have a Greek lambda. Perhaps use a font that has the Greek alphabet as well?

Otherwise, with this sort of thing, you probably need to do a few find/changes:

(1) Search for lD and replace with strikethrough (i.e. apply strikethrough to the combination). (I'm assuming you don't use strikethrough anywhere else in your document. If you do, use a different property that you don't use elsewhere, or create a new, temporary swatch and apply that.)

(2) Search for just l with strikethrough applied, and replace with the lambda + Symbol font as needed.

(3) Search for strikethrough and replace with nothing to remove.

 

You'd need to do something similar with the D. Actually, in step (1) perhaps you could apply subscript to both (if it's not being used elsewhere in the doc).

 

HTH,

Ariel

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Oh, and one other option which would work if all instances are the same size (i.e. in body text, or whatever), is to copy the correctly formatted pair to the clipboard, and then do a find/change and replace with the clipboard contents.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Unfortunately, this does not work because the word is not copied exactly as formatted...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Hi @aniri5j9ox8tw2ln, there are a few ways, but one way is to put a Grep Style into your paragraph style(s). For example:

Screenshot 2024-03-12 at 20.57.18.pngScreenshot 2024-03-12 at 21.00.31.pngAfter that, you can tweak the details, such as the subscript positioning, font etc.

- Mark

 

Edit 2024-03-12: added demo .indd, in case it helps. You can see the character styles I used for example.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Hi m1b.

I created the character styles for my word and made them under paragraph style>Grep style exactly as in your screenshot. But how can I now do it with the search/replace function that my wrong word is replaced with the Grep style? Under Replace format, I can't select a Grep style...

 

Edit: Wait a moment I check it out yet with your demo .indd

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Hi @aniri5j9ox8tw2ln, can you please first check your grep against my demo document attached to my post? If even one character is different it will probably not work.

 

If still no good, please post a screenshot showing the problem. Or post a demo .indd document.

- Mark

 

Lambda Symbol:

(?-i)\bl(?=D\b)

 

D after Lambda:

(?-i)\bl\KD\b

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

  1. Creeate a character Style for the lambda (greek font).
  2. Create a character style for the D
  3. in the Paragraph style go to the GREP, add a GREP style appy to l with positive lookahead D 
    l(?=D)​
  4. In the paragraph style go to the GREP, add another GREP style, with a positive lookbehind 
  5. d(?<=l)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Thanks to everyone! I managed to recreate it in my document with the demo.indd file.

I'm glad it worked out now!

 

Edit: I was too happy... the problem is that I have a lot of documents that contain this word "lD". Of course, my paragraph style with the grep styles is not available in these documents! Obviously, when I try to search for the word "lD" and replace it with the paragraph style, the window gives me the error message that this paragraph style does not exist in the document...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Hey @aniri5j9ox8tw2ln, here is a script that read a paragraph style from the active document and copy/update that style to every open document. It might help in your case.

- Mark

 

/**
 * Update Paragraph Style In All Open Documents.js
 *
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/need-help-because-of-a-tricky-find-amp-change-function/m-p/14483538
 */
function main() {

    var settings = {
        masterDoc: app.activeDocument,
        masterStyleName: 'My Paragraph Style',
    }

    var masterStyle = getThing(settings.masterDoc.allParagraphStyles, 'name', settings.masterStyleName);

    if (!masterStyle)
        return alert('Could not find master style "' + settings.masterStyleName + '" in document "' + settings.masterDoc.name + '".');

    updateStyle(settings.masterDoc, masterStyle, app.documents.everyItem().getElements());

}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Update Style');


/**
 * Propagate a style from master document to other documents.
 * If the style exists, it will be updated.
 * @param {Document} masterDoc - the document containing the masterStyle.
 * @param {ParagraphStyle|CharacterStyle} masterStyle - the style to propagate.
 * @param {Document|Documents|Array<Document>} doc - the destination document(s).
 * @param {TextFrame} [tempFrame] - a temporary text frame for duplicating the style (default: will create it).
 */
function updateStyle(masterDoc, masterStyle, doc, tempFrame) {

    var docs;

    if ('Document' === doc.constructor.name)
        docs = [doc];

    else if (
        'Array' !== doc.constructor.name
        && 'Documents' !== doc.constructor.name
    )
        throw Error('updateStyle: bad `doc` supplied.');

    else
        docs = doc;

    // how to get and set the style
    var getter = (getterAndSetterForStyle(masterStyle) || 0).getter,
        setter = (getterAndSetterForStyle(masterStyle) || 0).setter;

    if (!getter || !setter)
        return alert('Cannot handle "' + masterStyle.constructor.name + '".');

    // make some text in that style
    var tempFrame = masterDoc.textFrames.add({ contents: 'a' });
    setter(tempFrame, masterStyle);

    for (var i = 0; i < docs.length; i++) {

        doc = docs[i];

        if (doc === masterDoc)
            continue;

        if ('Document' !== doc.constructor.name)
            throw Error('updateStyle: bad `docs` supplied.');

        // if style already exists, rename it
        var existingStyle = getThing(getter(doc), 'name', masterStyle.name);

        if (existingStyle)
            // rename to avoid collision
            existingStyle.name = 'deleteMe';

        // duplicate it to the destination document
        var destinationFrame = tempFrame.duplicate(doc.layoutWindows[0].activePage);

        if (existingStyle)
            // replace with the master style
            existingStyle.remove(getThing(getter(doc), 'name', masterStyle.name))

        // clean up
        destinationFrame.remove()

    }

    // clean up
    tempFrame.remove();

};


/**
 * Returns getter and setter for the style type.
 * Currently handles CharacterStyles and ParagraphStyles.
 * @author m1b
 * @version 2024-03-13
 * @param {ParagraphStyle|CharacterStyle} style - the style to get and set.
 * @returns {Object} - { getter: setter: }
 */
function getterAndSetterForStyle(style) {

    return {
        CharacterStyle: {
            getter: function (doc) { return doc.allCharacterStyles },
            setter: function (textFrame, style) { textFrame.texts[0].appliedCharacterStyle = style },
        },
        ParagraphStyle: {
            getter: function (doc) { return doc.allParagraphStyles },
            setter: function (textFrame, style) { textFrame.texts[0].appliedParagraphStyle = style },
        }
    }[style.constructor.name];
}

/**
 * Returns a thing with matching property.
 * @param {Array|collection} things - the things to look through, eg. PageItems.
 * @param {String} key - the property name, eg. 'name'.
 * @param {*} value - the value to match.
 * @returns {*} - the thing.
 */
function getThing(things, key, value) {

    for (var i = 0; i < things.length; i++)
        if (things[i][key] == value)
            return things[i];

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Great! This script works perfectly...

Thank you very much for your support!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Good to hear!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

LATEST

By the way... In my research yesterday about this Greek sign, I found out that I had always pronounced it incorrectly. It's called Lamda and not Lambda! –.–

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines