Highlight all footnote superscripts

45 views Asked by At

I would like a way to highlight all of the superscripts that indicate footnotes, so that it's easier to see the footnote in a paragraph when skimming with your eyes. The goal is something like this:

enter image description here

I can't find any way to do this manually, or any add-on that will do this for me. Is there some way to do this with a script?

I tried the answer here Google Script: interacting with footnotes but it changes the style body of the footnotes without changing the style of superscript numbers themselves. I want to be able to format the superscripts all at once, but separately from the footnote bodies.

1

There are 1 answers

0
Tanaike On

Unfortunately, I couldn't find a method for managing the style of the superscript numbers of the footnotes from the Google Document service (DocumentApp). I'm worried that in the current stage, there might be no method for directly changing the superscript numbers of the footnotes in the methods of Google Document service. But, fortunately, I thought that when Google Docs API is used, your goal can be achieved. In this answer, I would like to propose a sample script using Docs API.

Sample script:

Before you use this script, please enable Google Docs API at Advanced Google services.

function myFuction() {
  const doc = DocumentApp.getActiveDocument();
  const docId = doc.getId();
  const obj = Docs.Documents.get(docId);
  const requests = obj.body.content.reduce((ar, e) => {
    if (e.paragraph) {
      e.paragraph.elements.forEach(f => {
        if (f.footnoteReference) {
          ar.push({ updateTextStyle: { textStyle: { backgroundColor: { color: { rgbColor: { red: 0, green: 1, blue: 0 } } } }, range: { startIndex: f.startIndex, endIndex: f.endIndex }, fields: "backgroundColor" } });
        }
      });
    }
    return ar;
  }, []);
  if (requests.length == 0) return;
  Docs.Documents.batchUpdate({ requests }, docId);
}

Testing:

When this script is run, the following result is obtained.

enter image description here

Note:

  • In this sample, it supposes that from your showing image, only the paragraphs are checked. If the superscript numbers of the footnotes exist in other parts except for the paragraphs, please modify the above script.

References: