Copy link to clipboard
Copied
Hi everyone,
Hoping someone can help out. I have a document with about 200 references (footnotes). I need to swap the position of the full stop (or period) so that it appear after the footnote.
For example, the current layout is:
Sentence.Footnote
(Or with numbers: Sentence.12)
And I need:
SentenceFootnote.
(Sentence12.)
Is there a way to use find and replace to swap these around? I can easily find the instances by using
.^F
but I don't know enough to code the swap. I don't fancy manually searching through 200 references to fix them all!
Any help would be very much appreciated.
Thanks
Andy
There must be scripts around to do that. but it's easier to rekey it than to look for it:
app.findGrepPreferences = app.findChangeGrepOptions = null;
app.findGrepPreferences.findWhat = '[[:punct:]]~F';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[1]);
}
This one swaps any punctuation and a following footnore number. Maybe the script should cater for strings of punctuation.
P.
Copy link to clipboard
Copied
Some example images of the text as it is:
And how it should look after:
Copy link to clipboard
Copied
There must be scripts around to do that. but it's easier to rekey it than to look for it:
app.findGrepPreferences = app.findChangeGrepOptions = null;
app.findGrepPreferences.findWhat = '[[:punct:]]~F';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[1]);
}
This one swaps any punctuation and a following footnore number. Maybe the script should cater for strings of punctuation.
P.
Copy link to clipboard
Copied
Hi Peter,
Many thanks for your reply. It took me a little while to figure out what to do with that code – I'm a complete novice when it comes to scripts! But once I had figured out how to get it into a suitable format and imported in to InDesign, it worked like a charm. So thanks again.
The only improvement would be if it could specify which type of punctuation – in this case I had some brackets and quotation marks that got swapped along with the full stops.
Andy
Copy link to clipboard
Copied
If you want to swap just the period and the footnote marker, use this:
'\\.~F'
And to use some spcific punctuation, more than one, e.g. period, comma, and semicolon, place them in brackets:
'[.,;]~F'
P.
Copy link to clipboard
Copied
Hi Peter,
Thanks for all of your scripts!
That script also works with an anchored object (which, like footnotes, is also deleted by search and replace)
I can't get it to change beyond one character.
Suppose I have an anchored object and then text in text in brackets:
~a\(\w{1,3}\)
And I want to change $2$1
How do you do that?
Thank you
Copy link to clipboard
Copied
To move anchors after a parenthetical following them, use this:
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '~a\\(\\w{1,3}\\)';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[-1]);
}