簡體   English   中英

Indesign(Javascript)腳注作為交叉引用目標破壞了編號

[英]Indesign (Javascript) footnote as crossref destination destroys numbering

是的,我有問題。 所以我有一個腳本,該腳本將所有腳注放在文檔的末尾,並從文本中的小數字到合適的尾注進行交叉引用。 現在我想添加一個反向鏈接,所以當我有一個長文檔(書)時,我不必手動回滾,而只需單擊尾注並返回即可。

到目前為止,我已經設法將尾注用作交叉引用源,但是我在交叉引用方面遇到了困難

當我將footnote.storyOffset用作目標時,它會擰緊文本中腳注的編號。 例如,第一個腳注僅從文本中消失,然后出現1,3,3,4,5,7 ...,依此類推。 為什么會這樣? 即時通訊只是使用此插入點作為目的地,突然它搞砸了一切。

將腳注數字手動放入文本中也就足夠了,但是我不知道如何刪除文本中的加擾數字。 我也可以使用下一個或上一個字符作為insertpoint,但是我如何到達那里?

我對這些indesign腳本非常陌生。 希望有人可以幫助我。

這是來源的關鍵部分:

stories[j].insertionPoints[-1].contents = SpecialCharacters.PAGE_BREAK; // add new page for notes
        stories[j].insertionPoints[-1].contents = 'Notes';// title
        footn = stories[j].footnotes;
        for (var i = 0; i < footn.length; i++)
        {
            stories[j].insertionPoints[-1].contents = '\r';
            endnote = footn[i].texts[0].move (LocationOptions.after, stories[j].insertionPoints[-1]);
            endnote.applyParagraphStyle (note_styles.first, false);
            if (i === 0)
            {
                endnote.numberingContinue = false;
                endnote.numberingStartAt = 1;
            }
            if (endnote.paragraphs.length > 1)
            {
                endnote.paragraphs.itemByRange (1,-1).applyParagraphStyle (note_styles.next, false);
            }
            //var stoff = footn[i].storyOffset;
            //stoff.contents = ''+(i+1);
            //stoff.applyCharacterStyle(note_styles.char_style_in_text);
            //stoff.appliedCharacterStyle.position= Position.superscript;

            backlink_destination = doc.paragraphDestinations.add (footn[i].storyOffset); // position of footnote in text
            endnote_destination = doc.paragraphDestinations.add (endnote.insertionPoints[0]);

            try
            {
                crb = app.activeDocument.crossReferenceFormats.add({name:'backlink'+i});
                crb.appliedCharacterStyle = note_styles.char_style_endnote;
                crb.buildingBlocks.add (BuildingBlockTypes.customStringBuildingBlock);
                crb.buildingBlocks.anyItem().customText = endnote.contents;
            }
            catch(_)
            {
                crb = app.activeDocument.crossReferenceFormats.item ('backlink'+i);
            };

            backlink_source = doc.crossReferenceSources.add (endnote, crb); // position of note at end of story
            endnote_source = doc.crossReferenceSources.add (footn[i].storyOffset, note_styles.cr_format);

            doc.hyperlinks.add(backlink_source, backlink_destination, {visible: false}); //add link from notes to text
            doc.hyperlinks.add(endnote_source, endnote_destination, {visible: false});
        } // for

修復:
我只是翻轉了制作交叉引用的順序。

我翻轉了以下幾行

backlink_destination = doc.paragraphDestinations.add (footn[i].storyOffset);
endnote_destination = doc.paragraphDestinations.add (endnote.insertionPoints[0]);

endnote_destination = doc.paragraphDestinations.add (endnote.insertionPoints[0]);
backlink_destination = doc.paragraphDestinations.add (footn[i].storyOffset);

backlink_source = doc.crossReferenceSources.add (endnote, crb);
endnote_source = doc.crossReferenceSources.add (footn[i].storyOffset, note_styles.cr_format);


endnote_source = doc.crossReferenceSources.add (footn[i].storyOffset, note_styles.cr_format);
backlink_source = doc.crossReferenceSources.add (endnote, crb);

doc.hyperlinks.add(backlink_source, backlink_destination, {visible: false});
doc.hyperlinks.add(endnote_source, endnote_destination, {visible: false});

doc.hyperlinks.add(endnote_source, endnote_destination, {visible: false});
doc.hyperlinks.add(backlink_source, backlink_destination, {visible: false});

我不知道為什么,但是按此順序工作就可以了...這並不能證明是好的軟件...
我怎么能以這個價格期望好的軟件?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM