13 Replies Latest reply on May 21, 2014 7:51 PM by Brian2025

    Character Style - Subscript Kerning

    Brian2025

      I am reading in a Word doc with many subscripts. The subscripts may contain multiple letters. For each subscript, I do a find/change to apply a basic ID subscript character style to the subscripts read from Word..

       

      BUT the problem is there is no kerning option (CS6). What I want to do is push every subscript just a bit to the right automatically (too close by default). I am aware there is a tracking option, but can't see how to address this with Find/Change since I thought you have to apply it to a selection. Perhaps there is a way to do it with GREP? For example, select the letter before the subscript (only if it is NOT a subscript letter) and select the first letter in the subscript and all apply tracking. Seems pretty complicated for something that should be simple though.

        • 1. Re: Character Style - Subscript Kerning
          gert verrept Level 2

          I found once this option for setting the right spacing for the french ' as in l'avenir:

          Create a char style (I called it apostroph) with the only option "tracking=60".

          In the para style enter the following code

          \d(?=')|[\l\u](?=')|(?<! )'

          with the char style "apostroph"


          Maybe with some adapting it works for the superscripts too.

          • 2. Re: Character Style - Subscript Kerning
            Peter Spier Most Valuable Participant (Moderator)

            In order to move the first subscript away from the character preceding it you need to find a way to identify that character, and as far as I can tell there is no way with GREP to differentiate formatting in the query, which means there is no way to do this with a GREP style. It might be doable by scripting, but I don't write scripts.

             

            I came up with a two-step find change, but it cannot be run multiple times without applying unwanted tracking on each subsequent run and I can't find a valid expression to prevent that. I suppose it could be a three-step, though, to remove the first tracking application and that might work. Here's the strategy:

            Find the subscripts, add a hairspace in front, and apply a character style with tracking and No Break to the whitespace.

             

            In order to prevent the reapplication of the tracking between subsequent subscript character if you re-run the query, you need to start by removing any subscript hairspaces:

            Find: ~| (that's the pipe symbol) and set the Find Format to subscript.

            Change: leave blank and leave the change format blank

             

            Now find your subscripts and add a hairspace in front:

            Find: .+ and set the Find Format to subscript

            Change: ~|$0 leave the change format blank

             

            Now add the tracking and No Break (so your words can't break across lines at the subscripts) to the hairspace you just inserted

            Create a character style whose only attributes are No Break and tracking that seems to be appropriate to move the subscript as much as you want. Since you want to increase the space, it may not be necessary to actually add any tracking at all, but this same method will work to tighten the spacing using a negative tracking value, and you still will want to apply the No Break, even if the hairspace is sufficient by itself.

            Find: ~| and set the Find Format to subscript

            Change: leave blank or set to $0 and set Change Format to the new character style

            • 3. Re: Character Style - Subscript Kerning
              Peter Spier Most Valuable Participant (Moderator)

              I forgot to mention that you can chain these operations together to run with a single command using a script like Peter Kahrel's Query Manager: A GREP query manager

              • 4. Re: Character Style - Subscript Kerning
                Peter Spier Most Valuable Participant (Moderator)

                Also, there is a VERY BIG downside to adding the whitespace. While it gives you what you want visually, it destroys the searchability for these words in both ID and a PDF. If someone over in scripting can find a way to identify the transition from normal to subscript and apply the tracking/kerning without whitespace, that would be a lot better.

                • 5. Re: Character Style - Subscript Kerning
                  Obi-wan Kenobi Adobe Community Professional

                  Hi,

                   

                  Maybe I don't understand but it is so easy to do this.

                   

                  1/ Create a char style "Virtual _Space". As:

                   

                  Capture d’écran 2014-05-21 à 12.49.43.png

                   

                  2/ Insert a grep style in the para style (if you want). As:

                   

                  Capture d’écran 2014-05-21 à 12.49.25.png

                   

                  3/ Launch the following regex. As:

                   

                  Capture d’écran 2014-05-21 à 12.48.47.png

                   

                  Done! As:

                   

                  Capture d’écran 2014-05-21 à 12.53.46.png

                  • 6. Re: Character Style - Subscript Kerning
                    Peter Spier Most Valuable Participant (Moderator)

                    OK, that's essentially the same thing I've done, but with the non-joiner instead of the hairspace. If the non-joiner doesn't break the searchability, that's better, but you still have the same problems of duplicating the spacing if you run the query a second time.

                    • 7. Re: Character Style - Subscript Kerning
                      Obi-wan Kenobi Adobe Community Professional

                      Hi Peter,

                       

                      No. Test it... You only accumulate NJ. To avoid it, you can modify the grep research as well to treat multiples researches. Simple.

                      • 9. Re: Character Style - Subscript Kerning
                        Peter Spier Most Valuable Participant (Moderator)

                        Sorry, that's not good enough. You need a system that does not require different queries for the first and subsequent runs.

                         

                        You could modify the GREP style, though, to apply the tracking to ~j(?<=[^~j]) so it only applied to the one before the actual subscript, but you'd need to be very careful about paragraph styles because there's a potential to add space with non-joiners that are not followed by subscripts.

                        • 10. Re: Character Style - Subscript Kerning
                          Peter Spier Most Valuable Participant (Moderator)

                          OK, I just reread the second query you posted and it would work on the first or subsequent runs, so I take back my comment.

                          • 11. Re: Character Style - Subscript Kerning
                            Obi-wan Kenobi Adobe Community Professional

                            Peter,

                             

                            There's only 1 grep research, the last I've done, and the added "virtual space" only concerns this case: a character followed by subscript.

                             

                            So, I don't see the problem. Of course, if NJ is already used for another reason, use NJNJ (or NJNJNJ...). As:

                             

                            Capture d’écran 2014-05-21 à 15.19.23.png

                            • 12. Re: Character Style - Subscript Kerning
                              Brian2025 Level 1

                              Well, I think this will do it

                               

                              But a few questions/comments:

                               

                              - To make life easy, I just need to this Find/Change once, after the Word document is imported.

                              - If I want this applied to the entire document (and not just any particular paragraph style), I just skip Obi-Wan's step 2 right?

                              - The GREP confuses me, although it works on my end. How does the Find/Change know to change to the newly defined Character style? All I see is "~j$0" in the Replace field. How does it know to go to "Virtual Space"? Again, it does seem to work, I just don't get it.

                              • 13. Re: Character Style - Subscript Kerning
                                Brian2025 Level 1

                                Thanks to both Peter and Obi-wan. I was able to see what is going on now and it seems to work. I still have some trial and error, but looking good so far