Highlighted

Finding the number of footnote digits with GREP

Community Beginner ,
Apr 03, 2019

Copy link to clipboard

Copied

I want to define a different paragraph style for footnotes of one and two digits (1–99), and footnotes of three digits (in order to increase the separating space for the latter). Can I find the number of digits of a footnote via GREP?

Or is there a better way to this? I aim to have a hanging indent for the footnote number, and then the footnote text aligned. I currently do this with a 5mm indent for the whole style and a -5mm first line indent for the hanging footnote number, which is separated from the text by a tab set to 5mm.

Most Valuable Participant
Correct answer by Jongware | Most Valuable Participant

tntype  wrote

Thanks Chad, a shame that footnotes are still treated like an afterthought in the leading page layout application.

They are not, really. (Actually they are, but for other numerous reasons I could list.) What you are after is equivalent to hoping to find the "2" in an automatic page number "123" -- this Just Won't Happen.

But footnotes can be scripted! The following very quickly written Javascript (so save as "jsx") will apply separate styles to 1-, 2-, and 3-digit footnotes. Make sure the text cursor is inside the story to process before running it.

oneDigitStyle = "one digit note";
twoDigitStyle = "two digit note";
threeDigitStyle = "three digit note";

story = app.selection[0].parentStory;

try {
for (n=1; n<10; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = oneDigitStyle;
}
for (n=10; n<100; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = twoDigitStyle;
}
for (n=100; n<1000; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = threeDigitStyle;
}
} catch (err)
{
/* most likely out of range footnote number, so we don't care */
}

Views

555

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Finding the number of footnote digits with GREP

Community Beginner ,
Apr 03, 2019

Copy link to clipboard

Copied

I want to define a different paragraph style for footnotes of one and two digits (1–99), and footnotes of three digits (in order to increase the separating space for the latter). Can I find the number of digits of a footnote via GREP?

Or is there a better way to this? I aim to have a hanging indent for the footnote number, and then the footnote text aligned. I currently do this with a 5mm indent for the whole style and a -5mm first line indent for the hanging footnote number, which is separated from the text by a tab set to 5mm.

Most Valuable Participant
Correct answer by Jongware | Most Valuable Participant

tntype  wrote

Thanks Chad, a shame that footnotes are still treated like an afterthought in the leading page layout application.

They are not, really. (Actually they are, but for other numerous reasons I could list.) What you are after is equivalent to hoping to find the "2" in an automatic page number "123" -- this Just Won't Happen.

But footnotes can be scripted! The following very quickly written Javascript (so save as "jsx") will apply separate styles to 1-, 2-, and 3-digit footnotes. Make sure the text cursor is inside the story to process before running it.

oneDigitStyle = "one digit note";
twoDigitStyle = "two digit note";
threeDigitStyle = "three digit note";

story = app.selection[0].parentStory;

try {
for (n=1; n<10; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = oneDigitStyle;
}
for (n=10; n<100; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = twoDigitStyle;
}
for (n=100; n<1000; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = threeDigitStyle;
}
} catch (err)
{
/* most likely out of range footnote number, so we don't care */
}

Views

556

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 03, 2019 1
Adobe Community Professional ,
Apr 03, 2019

Copy link to clipboard

Copied

The issue of indenting numbered items always comes down to preference. I understand your issue because when you get to 3 digits, the indent required for a single or even double-digit number often looks odd.

The problem is that the footnote number is a variable of sorts and InDesign doesn't find it as a digit it seems. Even choosing the "include footnotes" option in the GREP Find/Change doesn't find them. Honestly, I think GREP is overkill anyway because it's probably just as quick for you to manually highlight footnote numbers 1-9 and then 10 through 99 and apply a new style to it.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 03, 2019 1
Community Beginner ,
Apr 04, 2019

Copy link to clipboard

Copied

Thanks Chad, a shame that footnotes are still treated like an afterthought in the leading page layout application.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 04, 2019 0
Most Valuable Participant ,
Apr 04, 2019

Copy link to clipboard

Copied

tntype  wrote

Thanks Chad, a shame that footnotes are still treated like an afterthought in the leading page layout application.

They are not, really. (Actually they are, but for other numerous reasons I could list.) What you are after is equivalent to hoping to find the "2" in an automatic page number "123" -- this Just Won't Happen.

But footnotes can be scripted! The following very quickly written Javascript (so save as "jsx") will apply separate styles to 1-, 2-, and 3-digit footnotes. Make sure the text cursor is inside the story to process before running it.

oneDigitStyle = "one digit note";
twoDigitStyle = "two digit note";
threeDigitStyle = "three digit note";

story = app.selection[0].parentStory;

try {
for (n=1; n<10; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = oneDigitStyle;
}
for (n=10; n<100; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = twoDigitStyle;
}
for (n=100; n<1000; n++)
{
  story.footnotes[n-1].texts[0].paragraphs[0].appliedParagraphStyle = threeDigitStyle;
}
} catch (err)
{
/* most likely out of range footnote number, so we don't care */
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 04, 2019 3
Community Beginner ,
Apr 04, 2019

Copy link to clipboard

Copied

Oh, wow. I'm blown away, thank you very much indeed!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 04, 2019 0
Adobe Community Professional ,
Apr 04, 2019

Copy link to clipboard

Copied

Yeah I don't know that I can fully blame Adobe for this behavior. After all, they need to keep track of the footnote and it's relationship to the reference. So if you just go changing that number, I can see being able to really screw things up. @Jongware, that's a great script! I just have to remember to create the styles before running it. I'm gong to tuck this into my ID Script pocket for future use 😉

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 04, 2019 1
Contributor ,
Oct 19, 2020

Copy link to clipboard

Copied

Good Morning,

Just found this post, looks exactly what I was looking for but by I have no knowledge in writing scripts.

I tried to copy and paste the script into "ExtendScript Toolkit" app on mac, but I keep get an error. 
"Cannot write to file FootnotesFindDigits.jsx!

IOError: I/O error"

Screen Shot 2020-10-20 at 8.33.25 20-10-20.png

I'm sure i'm doing it all wrong,

 

Can you please help?

Thank you,

Shlomit

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 19, 2020 0