Back

If your email is not recognized and you believe it should be, please contact us.

Forum Replies Created

Viewing 15 posts - 241 through 255 (of 340 total)
  • Author
    Posts
  • in reply to: Footnote spacing issue #84113
    Peter Kahrel
    Participant

    Do you apply a character style to the footnote numbers (using a nested style)? If yes, check that character style and make sure that it doesn’t set a leading bigger than the paragraph’s leading.

    Peter

    in reply to: Grep #84070
    Peter Kahrel
    Participant

    Finding names by Grep has been discussed in this forum and elswhere many times. Do a google on ‘indesign grep names’ and you get many references that you can use.

    Peter

    in reply to: Apply Grep style to Paragraph Style #83997
    Peter Kahrel
    Participant

    In what way does that code not work? Works fine for me.

    Explain in some more detail what you want to do, because clearly I don’t understand it. You have a character style and a paragraph style. And you want to set up a Grep style in the paragraph style using that character style. Correct?

    in reply to: Apply Grep style to Paragraph Style #83989
    Peter Kahrel
    Participant

    Something like this:

    pstyle = app.activeDocument.paragraphStyles.add({name:"Paragraph – No Break"});
    pstyle.nestedGrepStyles.add ({
      appliedCharacterStyle: app.activeDocument.characterStyles.item('Character – No Break'),
      grepExpression: '. . .'
    });

    Peter

    in reply to: GREP to find first two words of a sentence #83973
    Peter Kahrel
    Participant

    What you want to avoid has no name as far as I’m aware because nobody objects to it. Some publishers want to avoid single-letter words (A, a, I) at the end of a line, but it still has no name.

    That the expressio doesn’t work for you is probably caused by the double spaces that Ari mentioned, and his suggested solutions should handle that.

    in reply to: GREP to find first two words of a sentence #83969
    Peter Kahrel
    Participant

    You want to keep together the first two words in a sentence. So you should exclude the period from the capture:

    (?<=\. )\w+? \w

    The so-called lookbehind (?<=\. ) reads “if preceded by a period and a space”. This means that the period and the space are included in the search, so they’re matched but not captured. Therefore the ‘no break’ will be applied only to the two words after the period+space.

    Note that the way you matched the first two words in a sentence — \w+ \w+ — doesn’t allow either of them to be hyphenated. The formulation above — \w+? \w — allows the second word to be hyphenated because only its first character is applied no-break. The first word is still applied no-break, so it won’t hyphenate. If you want to allow both words at the beginning of the sentence to kept together and to be hyphenated, use this GREP:

    Find what: \. \w+\K
    Change to: ~S

    and blank the Find format and Change format panes. The above query paraphrases as “replace the space between the first two words in a sentence with a non-fixed-width space”. The \K designates a so-called variable-width lookbehind.

    Peter

    in reply to: Calculation of Paragraph length(s) in a document #83028
    Peter Kahrel
    Participant

    That report is not suitable directly to select a paragraph from. But something in-between that fancy approach (which is possible but requires more scripting) and nothing at all is the script below. Open the document, run the script, and enter the story id (in the report) and the paragraph index separated by a space, slash, whatever non-numeric, and press Enter or click OK.

     (function () {
      var parId = prompt ('Enter a story id followed by the paragraph index:', '');
      if (parId !== null) {
       // var parts = parId.split(/\D/);
        var par = app.documents[0].stories.itemByID(Number(parts[0])).paragraphs[parts[1]];
        app.windows[0].activePage = par.parentTextFrames[0].parentPage;
        par.select();
      }
    }());
    in reply to: Grep to find all-italic paragraphs #83766
    Peter Kahrel
    Participant

    Made a mess of the codes. Sorry. But it’s still readable and correct.

    in reply to: Grep to find all-italic paragraphs #83765
    Peter Kahrel
    Participant

    Jim,

    .+ means 'one or more characters'.
    .* stands for 'zero or more characters', so that would find </i><i> as well. But . doesn't match the end-of-paragraph marker, and in this case that seems good because </i> at the end of a paragraph and <i> at the beginning of the next one seem legitimate. Or not?

    P.

    in reply to: Grep to find all-italic paragraphs #83751
    Peter Kahrel
    Participant

    Thanks for your kind words, Ari.

    P.

    in reply to: Grep to find all-italic paragraphs #83743
    Peter Kahrel
    Participant

    Jim,

    This is a good candidate for changing italics formatting to text tags like <i>. . .</i>. That way you can look for a single non-italic character in an italic environment. After the italic conversion, such a character would look like this: </i>è<i> (italic off, è, italic on). Replace that with è and finally change the italic text tags to italic formatting.

    To change italic formatting to tags:

    Find what: .+
    Find format: +Italic

    Change to: <i>$0</i>
    Change format: Regular (or Roman, Medium, Book — the non-italic stylen name of your font)

    Now replace </i>è<i> with è. Or place all accented characters in your document in a class: </i>[éëê]<i>. Or target all single characters: </i>.<i>.

    Finally, rstore italic formatting:

    Find what: <i>(.+?)</i>
    Find format: <nothing>

    Change to: $1
    Change format: Italic

    Peter

    Peter Kahrel
    Participant

    Well, actually, no need to play with the document’s Typeographic quotes setting. (Grep) Find ", replace with ~".

    in reply to: Templates and Language #83534
    Peter Kahrel
    Participant

    Here’s a scriptlet to change the language in all paragraph styles:

    styles = app.activeDocument.allParagraphStyles;
    for (i = 1; i < styles.length; i++) {
      styles[i].appliedLanguage = 'English: UK';
    }

    To do character styles as well, change allParagraphStyles to allCharacterStyles.

    Peter

    Peter Kahrel
    Participant

    A GREP expression can match things in one style only: you can’t specify different styles for a search. But if your ingredients lists are always preceded by the word ‘Ingredients’ and followed by the word ‘Directions’, then you can use this GREP to apply your ingredients style:

    Find what: (?s)(?<=Ingredients\r).+?(?=\rDirections)
    Change to: <Leave empty>
    Change format: <ingredients style>

    (?s) // Consider the text as a single line so that . matches \r
    (?<=Ingredients\r) // Match Ingredients and the following return
    .+? // Math up to . . .
    (?=\rDirections) // a return followed by Directions

    This expression matches any paragraphs between Ingredients and Directions. The \r characters (paragraph breaks) must be part of the lookaround to avoid applying the ingredients paragraph style to the Ingredients and Directions headings.

    Peter

    in reply to: Alphabetically order by last names #83288
    Peter Kahrel
    Participant

    No need for a table. Use a GREP to place the last names before the first names, sort the list, then use another GREP to place the last names after the first names:

    Find what: ^(.+?) (.+)
    Change to: $2@$1

    Sort the list

    Find what: ^(.+)@(.+)
    Change to: $2 $1

    Breakdown:

    ^ Start of paragraph
    (.+?) Match and capture up to (the first space)
    Match the first space
    (.+) Match and capture the rest of the paragraph

    Peter

Viewing 15 posts - 241 through 255 (of 340 total)