16 Replies Latest reply on Jun 18, 2016 3:11 PM by Obenreizer

    Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)

    Obenreizer Level 1

      ISSUE:
      Text which cites chemical equations, by convention, places equation numbers at the end of the sentences (i.e., adjacent to the right margin). I would like to not only place the equation number next to the right margin, but to do so with auto-numbering.

       

      BACKGROUND:

      System: InDesign CS5 on Mac El Capitan (OS X 10.11.5)

      Work-Around: I have read one 'trick' to accomplish the task is to [roughly described here] select WRC, World Ready Composer, from the Paragraph panel, set the equation (paragraph) to a foreign language which reads R-to-L, restart ID, change language back to English, and choose for the equation paragraph to run R-to-L, and use auto-numbering.
      Obstacle: I do not have a WRC option in the Paragraph panel options.  Worse still, I am lost as to exactly what WRC is, or how to get it in place.

      QUESTIONS:

      ¿Is there a way to accomplish the task (auto-numbering the last element of a sentence/paragraph) without having to "install" WRC?

      ¿ If not, how would I go about making adjustments so my Paragraph Panel produces a WRC option.

      Thank you in advance.

        • 1. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
          Obi-wan Kenobi Adobe Community Professional

          Not automatically, but only one click!

          [2 Grep find/replace, using a regex batcher as Multi/Find-Change of our clever friend Martinho da Gloria]

          If you add other eq you would want to number, "click" again!

          The new "click" won't treat the eq already treated again, only the new to be numbered!

          Simple and cool! 

           

          Capture d’écran 2016-06-17 à 12.36.20.png

          Capture d’écran 2016-06-17 à 12.37.07.png

          Capture d’écran 2016-06-17 à 12.37.22.png

          1 person found this helpful
          • 2. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
            Obenreizer Level 1

            A follow-up question wrt Multi/Find-Change. If I, say, have 50 equations in numerical order, and I  add a new a new equation in-between Eq 1 and Eq 2 . . . with Multi/Find-Change, would I need to 'one-click' the 49 equations which follow the newly-added equation at position 2, to renumber them?

             

             

            Obi-wan, I thank you.

            • 3. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
              Obi-wan Kenobi Adobe Community Professional

              Nope! Just add the new eq (para) and click! [The 2 regex play with a condition!]

              Only this para will be found and treated!

               

              I am actually very happy and it's your lucky day!

               

              … So, after having created [use these names]:

              • "Eq_0" para style, for equation paras

              • "Eq_Num" para style, for numbering paras

               

              Capture d’écran 2016-06-17 à 14.33.55.png

               

              As you can see, it's an "auto-numbering" para style! So, the numbering is "totally" automatic!

              If you add a new eq between "eq n°1" and "eq n°2" and want this new eq to be numbered, this new eq will become "eq n°2" and the following: 3, 4, 5, …!! Nice!

               

              • "Eq_0" condition [interesting to avoid to treat again what has been already treated -- Nice feature!]

               

              Just play these 2 regex:

               

              Capture d’écran 2016-06-17 à 14.31.35.png

              Capture d’écran 2016-06-17 à 14.31.50.png

               

              Be cool! 

              1 person found this helpful
              • 4. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                Obi-wan Kenobi Adobe Community Professional

                … If you prefer a simple script!    that works fine too!

                 

                main();
                function main() {
                  if (app.layoutWindows.length == 0) return;
                  changeObject = app.documents[0];
                  var doc = app.documents[0];
                  var style;
                  var options = app.findChangeGrepOptions.properties;
                  app.findGrepPreferences = NothingEnum.NOTHING;
                  app.changeGrepPreferences = NothingEnum.NOTHING;
                  // Query [[T1]] -- If you delete this comment you break the update function
                  try {
                  app.findChangeGrepOptions.properties = ({includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
                  app.findGrepPreferences.properties = ({findWhat:"\\r"});
                  app.findGrepPreferences.appliedConditions = []; 
                  style = getStyleByString(doc, 'Eq_0', 'paragraphStyles');
                  if (!style.isValid) throw Error('Missing find paragraphstyle [Eq_0] for query [T1]');
                  app.findGrepPreferences.appliedParagraphStyle =  style;
                  app.changeGrepPreferences.properties = ({changeTo:"\\r\\r", appliedConditions:["Eq"]});
                  changeObject.changeGrep();
                  } catch (e) {alert(e)}
                  app.findGrepPreferences = NothingEnum.NOTHING;
                  app.changeGrepPreferences = NothingEnum.NOTHING;
                  // Query [[T2]] -- If you delete this comment you break the update function
                  try {
                  app.findChangeGrepOptions.properties = ({includeFootnotes:true, kanaSensitive:true, widthSensitive:true});
                  app.findGrepPreferences.properties = ({findWhat:"\\r\\K\\r", appliedConditions:["Eq"]});
                  style = getStyleByString(doc, 'Eq_0', 'paragraphStyles');
                  if (!style.isValid) throw Error('Missing find paragraphstyle [Eq_0] for query [T2]');
                  app.findGrepPreferences.appliedParagraphStyle =  style;
                  app.changeGrepPreferences.properties = ({});
                  style = getStyleByString(doc, 'Eq_Num', 'paragraphStyles');
                  if (!style.isValid) throw Error('Missing find paragraphstyle [Eq_Num] for query [T2]');
                  app.changeGrepPreferences.appliedParagraphStyle =  style;
                  changeObject.changeGrep();
                  } catch (e) {alert(e)}
                  app.findChangeGrepOptions.properties = options;
                  app.findGrepPreferences = NothingEnum.NOTHING;
                  app.changeGrepPreferences = NothingEnum.NOTHING;
                };
                function getStyleByString(root, string, property) {
                  stringResult = string.match (/^(.*?[^\\]):(.*)$/);
                  var cStyleName = (stringResult) ? stringResult[1] : string;
                  cStyleName = cStyleName.replace (/\\:/g, ':');
                  remainingString = (stringResult) ? stringResult[2] : '';
                  var newProperty = (stringResult) ? property.replace(/s$/, '') + 'Groups' : property;
                  var cStyle = root[newProperty].itemByName(cStyleName);
                  if (remainingString.length > 0 && cStyle.isValid) cStyle = getStyleByString (cStyle, remainingString, property);
                  return cStyle;
                };
                

                 

                [ Comment:  The real interest of this script is not what it does but the real time to write it: 1 minute!!!    ]

                1 person found this helpful
                • 5. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                  Obenreizer Level 1

                  I am Hans, and this is only my third time to hold a saber. If you could coach me thru this.

                   

                  Here's where I'm at:
                  • I saved your script, dubbed "ObiWan_Script" to the scripts folder. The script now shows in my Scripts panel.
                  • I made a Para Style called "Eq_0".  It is not an auto-number; it is aligned right.

                  • I made a Para Style called "Eq_Num". It is auto-number, with parentheses; based on Eq_0.

                   

                  Here's what I'm at a loss as to what to do next:

                  • Do I need to make Queries T1 and T2? ... or is "ObiWan_Script" something intended for strictly for use with the Martinho da Gloria Multi/Find-Change addon you referred to earlier?

                  • But just in case, and to move things to a conclusion, I attempted to mimic the T1 and T2 frames you provided above. My modest attempts are below. I could not figure out how to match up the Find Format and Change Format parameters (see pics).

                   

                  I would appreciate any further guidance you could offer.

                   

                  T1.jpg

                  T2.jpg

                  • 6. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                    Olfar Level 2

                    Hi Obenreizer, hi Obi-Wan,

                    I do not recall what options were in bullets and numbering in  paragraph style in cs5 but you can do it in cc and CS6 using only paragraph style option. Please send me a screenshot of bullets and numbering window in cs5 for reminders.

                    • 7. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                      Obi-wan Kenobi Adobe Community Professional

                      ID file!

                       

                      Dropbox - FA-2168589_20160617_Eq.zip

                       

                      Take a look to the Conditions and Para Styles panel! 

                      [If needed, we'll talk later!]

                      • 8. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                        Obi-wan Kenobi Adobe Community Professional

                        Oups! ID CS5! \K since ID CS6! 

                         

                        Regex: Find what: (?<=\r)\r

                         

                        Sorry! 

                        • 9. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                          Obenreizer Level 1

                          Still no-go, but here's an update:

                           

                          • I left T1 the same (as previous pic); and based on previous message, changed T2 such that FIND WHAT  is now  (?<=\r)\r rather than \r\K\r (see attachment).

                          • Unfortunately, I couldn't open the file you sent. Got an error message re plugin. (Error message attached.)  I updated my CS5, but that didn't help.

                           

                          Status: still didn't work, but here's what happened when I ran ObiWan_Script as currently set up, perchance it helps you troubleshoot:

                          — If I have no paragraph set to Eq_0, then nothing happens when I run ObiWan_Script.

                          — If I have any paragraphs set to Eq_0, then when I run Script once, 1 line is added after each line with Eq_0 formatting; run it again, and it adds another 2 lines after each Eq_0, run a third time, it adds additional 4 lines after each, then 8, and so on I presume.

                           

                          ¿Was the indd file you sent saved in CS5 or lower, or would that help, if it were not?

                          ¿Does the status info above give you any new ideas to try?

                           

                          T2b.jpgMissingPlugin.jpg

                          • 10. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                            Obi-wan Kenobi Adobe Community Professional

                            Grrrrrrr!  

                             

                            My file is an ID CC 2015 file you can't open with CS5!

                            If somebody can save it in .idml. I can't do it now! Tomorrow for me! 

                            • 12. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                              Obenreizer Level 1

                              I only have it half-way working, and it's already a Wow! (and I'm not a particularly excitable guy).


                              What do I mean 1/2-way?  From the file you sent me, I am able to cut-and-paste RT-margin auto-numbering equations into my Chemistry document! Seriously, this is an absolute breakthrough for a non-expert ("fit-for-purpose") user who would like to write scientific matter in ID. At this point, consider me a happy camper.

                               

                              What about the other 1/2? The script doesn't work. I have to manually cut-and-paste to place each additional number from a previous one.  About the script issue, I tried a couple of things to report, perchance you have more patience. I believe the script is acting on two find/replace queries, T1 and T2.  So, I click in the document before a set of Eq_0 and Eq_Num paragraphs, go to find/replace, select T1, and click the Search button. Result:  "Could not find match." Same thing for T2.
                              I surmise that ObiWan_Script is working fine, but the T1 and T2 queries are incorrectly structured—if they don't find anything, then OviWan_Script has nothing on which to act.   FWIW, the current T1 and T2 setting are provided in the attached pics.   ¿Any ideas on getting the script to work?

                               

                              Gratefully yours.

                              T1c.jpg

                              T2c.jpg

                              • 13. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                                Obi-wan Kenobi Adobe Community Professional

                                Hans,

                                 

                                Show me screenshots of your 2 para styles Eq_0 and Eq_Num options [first tag when you open the para style settings window]?

                                Conditions window too – condition name: Eq?

                                 

                                Thanks!

                                • 14. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                                  Obenreizer Level 1

                                  Two files attached:
                                  1. Eq_0, general tab

                                  2. Eq_Num, general tab

                                   

                                  Regards

                                   

                                  Eq_0.General.jpg

                                   

                                  Eq_Num.General.jpg

                                   

                                  • 15. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                                    Obi-wan Kenobi Adobe Community Professional

                                    Humm!

                                     

                                    "T1" searches all para end (\r) with "Eq_0" para style applied and replace by \r\r.

                                    That means that we have now the equation para + a blank para below with the same para style (Eq_0).

                                    By applying a condition, we avoid to search paras already treated.

                                     

                                    "T2" searches all blank para preceded by a carriage return, all of them have the same para style applied: "Eq_0".

                                    That means that T2 searches all the paras created by T1 and apply to them "Eq_Num" para style (counter)!

                                     

                                    So, if you launch T1 with "all replace", then T2 with all replace", it's done!

                                     

                                    About the script, it doesn't work for you because there a "\K" Grep syntax in it (line 26).

                                    It has been written for ID CC 2015! Not really sure it could word for CS5.

                                     

                                    I'm not at my office until tuesday! If always a problem, send me a PM!  Good luck! 

                                    • 16. Re: Desire autonumbering at end of sentence (my CS5 doesn't have WRC option)
                                      Obenreizer Level 1

                                      Obi-wan,

                                       

                                      I am extremely grateful to you. In looking for a solution, I kept going back to the web every half year or so, looking for an answer. No one had a remedy—until you took an interest.


                                      But I suppose, at least for me, I am as impressed with your patience as your skill set. When looking for help, the price I am usually willing to pay is to tolerate some snippy expert's condescension. (But then again, anyone within an area of expertise who is worth their weight in salt can belittle those on the outside, now can't they—hardly something to boost one's ego.)  Your demeanor and eagerness to help was an unexpected surprise. Of particular note, thank you for finding a file I needed, converting it to CS5 for me, and remembering to send it to me...twice, to make sure I got the correct copy.

                                      And so, a hat-tip to you, Master Obi-wan.

                                      Cheers.