使用尾註和另一個文件的編號

使用尾註和另一個文件的編號

您可以使用另一個文件產生的尾註來提供目前文件嗎?

在此輸入影像描述

我計劃的工作流程是將尾註放入sepfootnotes文件中,在 中標記每個註釋的位置DocA.tex,然後在 中列印每個註釋的內容DocB.tex。 MWE 是DocB.tex。我用來flowfram將 DocA 作為 PDF 嵌入到靜態框架中。這允許三列流程框架從 DocA 列印非常廣泛的註釋。

\documentclass[10pt]{book}
\usepackage[T1]{fontenc}
\usepackage{newtxtext}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{flowfram}
\usepackage{ragged2e}

\geometry{margin=0pt}
\setlength{\RaggedRightParindent}{\parindent}

\makebackgroundframe

\newstaticframe*{5.497in}{7.329in}
{3.003in}{3.671in}[pagegraphic]

\newflowframe{2.493in}{9.976in}
{0.30in}{0.6in}[leftcol]

\newflowframe{2.493in}{2.780375in}
{3.003in}{0.6in}[middlecol]

\newflowframe{2.493in}{2.780375in}
{5.706in}{0.6in}[rightcol]

\newcommand{\pagebox}[1]{%
{\setlength{\fboxsep}{1pt}\setlength{\fboxrule}{1pt}%
\fcolorbox{black}{white}{#1}}}

\setstaticframe{1}{backcolor={[rgb]{0.976,0.937,0.78}}}
\setstaticframe{2}{border=pagebox, offset=-2pt, backcolor={[rgb]{1, 1, 1}}}

\begin{document}

\RaggedRight

\begin{staticcontents*}{pagegraphic}
\includegraphics[page=3, scale=0.9448]{TestiPadSize.pdf}
\end{staticcontents*}

\lipsum

\end{document}

我意識到我可以手動完成此操作,只需輸入對 DocA 上出現的每個註釋的引用,但隨著文件的更改,我更喜歡使用 DocA 中的計數器來完成此操作,因此編號和位置會準確。

我的第一個想法是重寫\newfootnotes命令以sepfootnotes使用 DocA 的.ent檔案。但我不知道足夠的 LaTeX 來實現這一點。這是最好的方法嗎?是否有一個包已經可以處理這個問題了?

我通讀了這個帖子其中涉及reledmac.不過,似乎有很多我不需要的開銷和功能。

答案1

這並不簡單,但也不是很難。基本想法與您所建議的完全相同:將第一個文件中的「註釋」寫入外部文件,然後將其讀入第二個文件中。

那麼,先處理第一點:

在第一個文件中—您稱之為 DocA:

\documentclass{article}
\makeatletter
% First we need a new "write".
\newwrite\notesdoc
\immediate\openout\notesdoc=\jobname.notes
\newcounter{enotecounter}
\newcommand{\externalnote}[1]{%
  \refstepcounter{enotecounter}%
  \textsuperscript{\arabic{enotecounter}}
  \protected@write\notesdoc{}{\string\extnote{\arabic{enotecounter}}{#1}{\thepage}}}
\makeatother
\begin{document}

Here is some text.\externalnote{Here is a note. It is a long note,
and I am hoping that it will end up going over several lines.} And
here is another\externalnote{Another}

\clearpage

Here is some text on the next page\externalnote{And this is the text.}

\end{document}

其作用是簡單地透過做出適當的標記來「編寫」註釋,然後將文字實際放置在外部文件「\jobname.notes」中。出於顯而易見的原因,我們透過將命令寫入該檔案來實現這一點。

然後是第二個文件,它必須讀入先前寫入的文件。一個問題:我們需要一些工具來將註解與頁面配對。為此,我們假設從第 1 頁開始(並且我們明確地將靜態圖像放置在該頁面上):此後我們查看註釋的頁碼是否已「更改」:如果已更改,我們也會清除該頁面並插入下一頁靜態圖像。

注意——如果 DocA 中有任何頁面沒有註釋,這將會失敗:它們將被簡單地忽略。但我們不是想寫一個包,只是想寫一個特定問題的解決方案!

\documentclass[10pt]{book}
\usepackage[T1]{fontenc}
\usepackage{newtxtext}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{flowfram}
\usepackage{ragged2e}

\newcommand{\thispage}{1}

\makeatletter
\newcommand{\extnote}[3]{%
  \edef\@tempa{#3}
  \if\@tempa\thispage
  \else
  \clearpage
  \begin{staticcontents*}{pagegraphic}
    \includegraphics[page=#3, scale=0.6]{200219a.pdf}
  \end{staticcontents*}
  \fi
  \par\textbf{#1}.\quad#2}
\makeatother

\geometry{margin=0pt}
\setlength{\RaggedRightParindent}{\parindent}

\makebackgroundframe

\newstaticframe*{5.497in}{7.329in}
{3.003in}{3.671in}[pagegraphic]

\newflowframe{2.493in}{9.976in}
{0.30in}{0.6in}[leftcol]

\newflowframe{2.493in}{2.780375in}
{3.003in}{0.6in}[middlecol]

\newflowframe{2.493in}{2.780375in}
{5.706in}{0.6in}[rightcol]

\newcommand{\pagebox}[1]{%
{\setlength{\fboxsep}{1pt}\setlength{\fboxrule}{1pt}%
\fcolorbox{black}{white}{#1}}}

\setstaticframe{1}{backcolor={[rgb]{0.976,0.937,0.78}}}
\setstaticframe{2}{border=pagebox, offset=-2pt, backcolor={[rgb]{1, 1, 1}}}

\begin{document}

\RaggedRight

\begin{staticcontents*}{pagegraphic}
\includegraphics[page=1, scale=0.6]{200219a.pdf}
\end{staticcontents*}

\input{200219a.notes}

\end{document}

放置(第一個)靜態內容頁面後,我們只需輸入註釋文件,該文件依次列印註釋,並在必要時更改頁面和「靜態」框架。

然後我們運行 DocA,然後運行 DocB。

結果:

第1頁 第2頁

如前所述:這不是超級強大的(也沒有經過充分測試)。如果筆記超過一頁,它就會失敗。如果有一個頁面沒有註釋,它將會嚴重失敗。如果您想新增文字請注意,您可能可以這樣做,但是您需要為 DocA 編寫一個額外的命令來執行此操作。基本上,一旦全部設定完畢,您真正想要寫入的所有內容都會進入 DocA:DocB 只是一種包裝器 - 儘管您完全可以在之前或之後添加文字。

編輯新增順便說一句,我想說這reledmac完全正確,而且並不過分。但是YMMV。

相關內容