Copy link to clipboard
Copied
I'm designing a textbook with a lot of footnote reference numbers. They all have the Characterstyle "Footnote_Numbers" (I made them pink). Two things: 1) The punctuation is now AFTER the Footnote Numbers, instead of before. 2) There are also footnote numbers in the middle of a scentence and in those cases I need to remove the space that precedes those footnote references, because those all have a white-space before the superiour digits. This white-space has NO character style. I'm trying to get a script or GREP to solve both problems.... Hope one of you wizzards has a solution? THANKS!!
This has come up before, several times. Google finds e.g. this post:
The script there looks for
'[[:punct:]]~F'
to move punctuation after the footnote reference, which is the opposite of what you want. So you should change the above to
'~F[[:punct:]]'
You then deal with the spaces in a separate query, no script required:
Find what: \h(?=[[:punct:]]?)
Change to: <leave empty>
That
...Manually -- the thought!
Here's another approach. The script now looks for anything in the FootnoteNumbers style, and if the following character is punctuation, it's moved.
You'll have to run it against a version of the document as it was before you ran the previous script.
app.findGrepPreferences = null;
app.findGrepPreferences.appliedCharacterStyle =
app.activeDocument.characterStyles.item('Footnote_Numbers');
found = app.activeDocument.findGrep();
for (i = found.length-1; i >= 0; i-
...
Copy link to clipboard
Copied
This has come up before, several times. Google finds e.g. this post:
The script there looks for
'[[:punct:]]~F'
to move punctuation after the footnote reference, which is the opposite of what you want. So you should change the above to
'~F[[:punct:]]'
You then deal with the spaces in a separate query, no script required:
Find what: \h(?=[[:punct:]]?)
Change to: <leave empty>
That is, look for a (horizontal) space followed a punctuation mark (optionally) and a space. Replace the space with nothing.
Copy link to clipboard
Copied
Unluckily, this solution doesn't work, nothing happens when running the script:
app.findGrepPreferences = app.findChangeGrepOptions = null;
app.findGrepPreferences.findWhat = '~F[[:punct:]]';
found = app.documents[0].findGrep();
for (i = found.length-1; i >= 0; i--) {
found[i].characters[0].move (LocationOptions.AFTER, found[i].characters[1]);
}
What do i do wrong? To explain my problem again: in my text some numbers are superiour and they have the Characterstyle "Footnote_Numbers". The punctuation is now AFTER these superiour numbers instead of before.
Copy link to clipboard
Copied
> in my text some numbers are superiour and they have the Characterstyle "Footnote_Numbers".
Are those superior numbers real footnote references? (Sorry, I have to ask.)
Copy link to clipboard
Copied
No, good question! I have the impression that that is the core of my problem, they are just superior numbers, the link to the references is broken...
Copy link to clipboard
Copied
So the footnote texts are in separate frames at the foot of the pages, correct? If not, what does it look like? Can you show a screenshot? Please enable the display of frames and hidden characters. Or post your document.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
the footnotes itself are at the end of the chapter.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
So they're endnotes, not footnotes 🙂
You need this version of the script:
app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = '\\d+[[:punct:]]';
found = app.activeDocument.findGrep();
for (i = found.length-1; i >= 0; i--) {
if (found[i].characters[0].appliedCharacterStyle.name == 'Footnote_Numbers') {
found[i].characters[-1].move (
LocationOptions.BEFORE, found[i].insertionPoints[0]
);
}
}
Copy link to clipboard
Copied
Hihi, very much ENDNOTES! I keep calling them all footnotes, but now I hopefully am cured. I am getting an error though.
Copy link to clipboard
Copied
I corrected the script, above (= should be ==). I didn't see the error here because of, well, because. Sorry.
Copy link to clipboard
Copied
You are a hero! How happy one can be when a script works... ridiculous. What I forgot was that there are superiour numbers with more than 1 reference. They even have punctuation in that style "Footnote_Numbers" as you can see, I think I will correct that by hand?
Copy link to clipboard
Copied
Manually -- the thought!
Here's another approach. The script now looks for anything in the FootnoteNumbers style, and if the following character is punctuation, it's moved.
You'll have to run it against a version of the document as it was before you ran the previous script.
app.findGrepPreferences = null;
app.findGrepPreferences.appliedCharacterStyle =
app.activeDocument.characterStyles.item('Footnote_Numbers');
found = app.activeDocument.findGrep();
for (i = found.length-1; i >= 0; i--) {
x = found[i].parentStory.characters[found[i].insertionPoints[-1].index];
if ('.,;!?'.indexOf(x.contents) >= 0) {
x.move (LocationOptions.BEFORE, found[i].insertionPoints[0]);
}
}