4 Replies Latest reply on Dec 17, 2009 7:18 AM by stownshend

    Insert Footnote

    stownshend

      I have a book with hundreds of endnotes that need to be converted into footnotes. Does anyone know of a script to insert a footnote and format it? I think what would need to happen is that you would be able to copy the endnotes, one at a time, click an insertion point where the footnote reference would be and run the script to insert the text as a footnote and apply the style "footnote" to it; it would be nice if it would add a tab before the footnote number too! I can do it fairly efficiently just uting keyboard shortcuts but I could halve the time with a script.

      Any advice would be greatly appreciated!

        • 1. Re: Insert Footnote
          [Jongware] Most Valuable Participant

          Sure. Copy (or Cut) something, and make sure there is no hard return at the end (that's real ugly, as it would add a blank line at the bottom of the note). Then go to the position where you want the footnote, then run this script:

           

           

          fn = app.selection[0].footnotes.add();
          fn.texts[0].insertionPoints.item(-1).select();
          app.paste();
          fn.texts[0].appliedParagraphStyle = "note";
          
          (Replace the style name "note" with the one you want.)
          There is no need for the script to insert a Tab after the footnote number; you can set that in the Document Footnote Options (adding one tab is even the default setting).
          Fastest way to do this would seem to open another window, focused on the end notes. Switch windows, cut, switch windows, click the right place, run script. Repeat until done, or sufficiently bored to call it a day. For hyperspeed, add a shortcut key to the script!

           

          [Ed.] I should probably tell you it's a Javascript, so save it with extension ".jsx".

          [Ed#2] Oops. Tab should go before the note number. Okay, add this line after the last one:

           

          fn.insertionPoints.item(0).contents = "\t";
           
          

           

           

          (What's with the ugly formatting under a piece of code? Another jive-up!)

          • 2. Re: Insert Footnote
            stownshend Level 1

            Thank you very much!! That works great and will save me tons of time (and I did make a shortcut to the script). The only refinement would be if it could be made to apply the style without stripping out the formatting (italics) that appear in some of the notes.

            • 3. Re: Insert Footnote
              [Jongware] Most Valuable Participant

              O-o-o -- the safe way to handle local overrides is to replace them with character styles (and my own preptext does this).

              Try this new script; the applyParagraphStyle function has an optional argument 'override', which, when set to false, will not override locally applied formatting.

               

              fn = app.selection[0].footnotes.add();
              fn.texts[0].insertionPoints.item(-1).select();
              app.paste();
              // fn.texts[0].appliedParagraphStyle = "note";
              fn.texts[0].applyParagraphStyle(app.activeDocument.paragraphStyles.item("note"),false);
              fn.insertionPoints.item(0).contents = "\t";
              

              • 4. Re: Insert Footnote
                stownshend Level 1

                Thank you again, that works perfectly.