使用其他文档的尾注和编号

使用其他文档的尾注和编号

您能否使用另一个文档生成的尾注来补充当前文档?

在此处输入图片描述

我计划的工作流程是将尾注放在一个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。

相关内容