13 Replies Latest reply: May 31, 2012 5:33 PM by MadMac55 RSS

    I have a GREP Find to select a fraction-now, how to style it?

    iBabs2 Community Member

      Hello,

      I have been playing around with GREP on my own and with the help of others on this forum.

      Here is my next challenge, I have come up with a way to find a fraction. Here is my GREP code:

       

      (?<!/)\d+/\d+(?!/)

       

      lets say it finds 3/4

       

      Now I need to do the following

      I have a character style for the numerator, the slash and the denominator and I need to apply them.

      Then, if I can figure that out, I will need to do a lookahead or lookbehind to change the kerning between those 3 characters.

      I have tried all kinds of stuff, but I have not been succesful. Is this even possible?

       

      Anyone out there up for the challenge ;-)

      thanks

      babs

        • 1. Re: I have a GREP Find to select a fraction-now, how to style it?
          L. Tournier Community Member

          Hello,

          At first, I think this regex (?<!\d)(?<!\d/)\d+/\d+(?!/\d)(?!\d) is better to find only fractions, and not a date like 12/06/87.

          Why don't you apply kerning to the whole fraction ? Why don't you applied style Fraction with OpenType ?

          • 2. Re: I have a GREP Find to select a fraction-now, how to style it?
            P Spier CommunityMVP

            I'm not up to the challenge, but I wonder how your GREP know the difference between 13/16 (one and three sixteenths) and 13/16 (thirteen sixteenths)?

             

            I think you are on very shaky ground any time you try to auto-format fractions.

            • 3. Re: I have a GREP Find to select a fraction-now, how to style it?
              mattaca Community Member

              This sounds a job for GREP styles. We've done this when we needed fractions and aren't using an opentype font. The nice thing is, once you build it into your paragraph style, it will ALWAYS apply it when it sees a fraction, even if you type it in later. In other words, you'll never need to run a find/change for this again.

               

              In your paragraph style dialog box, select GREP styles and set it up as shown in the screen shot below. If you want it to look for fractions with more than one digit in the numerator or denominator, add a plus after the "d". Just keep in mind, this will automatically find things like dates (6/8/10) or things like "50/50" that you may not want set as fractions, so be careful. You might need to create a fourth GREP style once you figure out where you want the kerning applied, or if you want to change the tracking for the entire unit (numerator, slash, and denominator).

               

              Let us know how it goes!

               

              Screen shot 2010-06-09 at 10.57.44 AM.png

              • 4. Re: I have a GREP Find to select a fraction-now, how to style it?
                mattaca Community Member

                Oh, and you can disregard the third GREP style in that screenshot. It was keep text in parens from getting bolded (a different issue).

                • 5. Re: I have a GREP Find to select a fraction-now, how to style it?
                  iBabs2 Community Member

                  Hello everyone!!!

                   

                  @ L. Tournier-The font we use is a proprietary font and doesn't have the fractions built in. Thanks for the alternate way to do the GREP search, all of that is so helpful and works for any scenario.

                   

                  @ Peter- Actually L. Tournier's GREP finds all the possibilities...oh, and when am I not on shaky ground ;-)

                   

                  @ mattaca-that looks very very promising-unfortunately the office am in today is using CS3, so I will have to wait till late tonight before I can try this at home on CS4...This is the area I was definitely looking at to possibly be my answer, but since I am just learning GREP, I don't have all the sequence stuff learned yet... I will play with this tonight and certainly post tomorrow how I made out!!

                   

                  thanks soo much to everyone!!!

                  babs

                  • 6. Re: I have a GREP Find to select a fraction-now, how to style it?
                    peter at knowhowpro Community Member

                    iBabs2 wrote:

                     

                    Hello,

                    I have been playing around with GREP on my own and with the help of others on this forum.

                    Here is my next challenge, I have come up with a way to find a fraction. Here is my GREP code:

                     

                    (?<!/)\d+/\d+(?!/)

                     

                    lets say it finds 3/4

                     

                    Now I need to do the following

                    I have a character style for the numerator, the slash and the denominator and I need to apply them.

                    Then, if I can figure that out, I will need to do a lookahead or lookbehind to change the kerning between those 3 characters.

                    I have tried all kinds of stuff, but I have not been succesful. Is this even possible?

                     

                    Anyone out there up for the challenge ;-)

                    thanks

                    babs

                    Hi, Babs:

                     

                    Looks like you're getting good advice on rolling your own GREP solution, but you might also want to look at Dan Rodney's free Proper Fraction script, and his Proper Fraction Pro commercial version - InDesign Scripts - Proper Fraction, Make Book Jacket and More .... Also, DTP Tools' commercial Blatner Tools product has a fraction tool - Blatner Tools for Adobe InDesign - DTP Tools. I'm not commercially involved with either vendor.

                     

                    HTH

                     

                    Regards,

                     

                    Peter

                    _______________________

                    Peter Gold

                    KnowHow ProServices

                    • 7. Re: I have a GREP Find to select a fraction-now, how to style it?
                      Jeffrey_Smith Community Member

                      If you don't have that many fraction variations to replace, you could just do a text search of 3/4 and replace with Clipboard Contents, Formatted. In which you have already formatted the fraction 3/4 and a copy resides on your clipboard.

                      • 8. Re: I have a GREP Find to select a fraction-now, how to style it?
                        iBabs2 Community Member

                        hi!

                         

                        @ Peter at knowhowpro- yes, I have looked at Dan Rodny's proper fraction, but unfortunately with the free one, we can't play with the custom kerning and baseline shifting we use. Trying to code it by hand to give us the most flexibility in the styling..We will look at the commercial version if we are still having trouble. I def, want to check out Blatner Tools...I forgot that was coming out ;-)

                         

                        @ Jeffrey- Yes, it would be a large catalog with many of them...but, I didn't know you could do a find and change based on clipboard contents Formatted!! That is so cool!!!! I can definitely use that for other things...and, honestly, if what i am trying to do doesn't work, that may be one great backup plan.

                         

                        thanks!

                        babs

                        • 9. Re: I have a GREP Find to select a fraction-now, how to style it?
                          iBabs2 Community Member

                          @Mattaca!!

                           

                          WOW-your solution just about worked... Two things (One thing I added, One thing not working)

                           

                          1. I did add a + sign after the d's for fractions that had 2 digits. like 12/16.

                          2. For some reason my slash character style is not attaching itself to the / in the fraction.

                          Here is my snapshot, I think it looks like yours exactly, but would you mind seeing if I am doing anything wrong.

                          Picture 28.png

                           

                          also-just curious..I noticed when I highlight a fraction number, it doesn't highlight the character style in the character panel? Is this because it is does this in  the GREP area? It's no major deal, but if someone else wanted to know what style the numerator was using, it doesn't highlight. I did make changes to the character style, just to make sure it was attached, and it was, but this is how I realized the / was not taking the slash style.

                           

                          THANKS!!!

                          babs

                          • 10. Re: I have a GREP Find to select a fraction-now, how to style it?
                            [Jongware] Community Member
                            2. For some reason my slash character style is not attaching itself to the / in the fraction.

                             

                            The GREP you copied -- \(.+\): -- was not relevant to your problem ...

                             

                            To pick up a slash between two digits, use this one:

                             

                            (?<=\d)/(?=\d)

                             

                            Unfortunately, it's impossible to have it automagically ignore dates (01/02/10), part numbers (803/50130-5), and the likes. But if you are sure those never occur in your document (and in this particular style), it should work just fine & dandy.

                            • 11. Re: I have a GREP Find to select a fraction-now, how to style it?
                              iBabs2 Community Member

                              Hello Jongware!!

                               

                              That did it!!!

                               

                              Ahhhhhhhhhhhhhh...life is very good

                               

                              Thanks to everyone out there who helped with this!!! I'm sure others will find it all very helpful!

                               

                              babs

                              • 12. Re: I have a GREP Find to select a fraction-now, how to style it?
                                iBabs2 Community Member

                                Hi everyone,

                                 

                                OK...I have been playing with a bunch of these and I was working in CS4 where I can put them in as a style.

                                I have a character style that is called superscript, that automatically makes a ® superscript when it is typed, and that is working fine.

                                Then I added my lookahead for any TM or ® to add a 100 tracking in between the letter and the tm or ®. It does it if I have the type in the box and apply my style to the whole box. But, if I go in and make changes to the text, the ®-superscript automatically happens when I type a new one, but the tracking doesn't automatically happen. If it is in the GREP style of the paragraph style, shouldn't it do it dynamically?

                                 

                                Here is my image.

                                 

                                Picture 29.png

                                thanks!!

                                babs

                                • 13. Re: I have a GREP Find to select a fraction-now, how to style it?
                                  MadMac55 Community Member

                                  Babs, could you share your character style prefs for numerator slash and denominator?   I am trying to reverse engineer and have a terrible deadline.

                                  thanks to Babs, Jongware and everyone !   Really helpful.