【问题标题】:Inlining the LaTeX \input Command内联 LaTeX \input 命令
【发布时间】:2015-09-18 19:33:39
【问题描述】:

我正在寻找一个程序来递归内联 LaTeX 文件中的所有 \input{} 命令。 “递归”是指迭代地进行内联,直到最终的 LaTeX 文件中没有 \input{} 命令。

我已经遇到过flatten 包。但是,出于某种原因,我的 TeXLive 发行版没有安装它。当我执行命令sudo tlmgr show flatten 时,我收到错误消息:tlmgr: cannot find flatten。因此,我正在寻找更标准且更易于安装的替代工具。

【问题讨论】:

  • 我不明白。您想要一种方法来创建一个新文件,其中 \input{FILE} 的每个实例都已替换为 FILE 的内容?这个问题可能会更好地概括并标记为bashshell-scripting 等。(但是,如果你这样做,你可能最终会有人粘贴flatten 的内容!)
  • @Geoff:感谢您的建议。我添加了更多标签以获得更多关注。
  • @Geoff:小心 shell 脚本建议。 “有些人在遇到问题时会想‘我知道,我会使用正则表达式。’现在他们有两个问题。” — 杰米·扎温斯基
  • @Ken,哈哈。是的,但是 shell 脚本和正则表达式是 fun.

标签: bash latex shell tex text-processing


【解决方案1】:

您为什么不直接从 CTAN(您在问题中提供的链接)下载 flatten 并手动安装?

编辑:应用以下补丁来修复构建错误。

commit 4d62b79c5145d2b5556487b483d92df797564a18
Author: Ken Bloom <kbloom@gmail.com>
Date:   Thu May 27 12:45:49 2010 -0500

    fix build errors

diff --git a/flatten.l b/flatten.l
index 85ffee5..da12d2d 100644
--- a/flatten.l
+++ b/flatten.l
@@ -62,6 +62,7 @@ char FILE_DATE[] = "October 1995";
  */


+#include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -641,7 +642,7 @@ FILE *f3;
 char *strsave(s)
 char *s;                           /* string to be saved */
 {
-  char *p, *malloc();
+  char *p;

   if ((p = malloc(strlen(s)+1)) != NULL) {
      strcpy(p, s);
@@ -834,4 +835,4 @@ void initialise_senv()
   strcpy(path_sep," :;");                /* path seperators */
   dir_cat = '/';                         /* directory catenation char */
   senv_debug = 0;                        /* debugging off */
-}                                      /* end INITIALISE_SENV */
\ No newline at end of file
+}                                      /* end INITIALISE_SENV */
diff --git a/getopt.c b/getopt.c
index 5131cfa..b35cf51 100644
--- a/getopt.c
+++ b/getopt.c
@@ -6,6 +6,7 @@
 /* getopt()  from Don Libes "Obfuscated C" */


+#include <string.h>
 #include <stdio.h>

 /* getopt()  -- parse command line arguments */
@@ -21,10 +22,6 @@
      fprintf(stderr, s, (unsigned)strlen(s));\
      fprintf(stderr, errbuf, 2);}

-extern int strcmp();
-extern char *strchr();
-extern int strlen();
-
 int opterr = 1;    /* getopt prints errors if this is one */
 int optind = 1;    /* token pointer */
 int optopt;        /* option character passed back to user */
diff --git a/srchenv.c b/srchenv.c
index fa3e8d8..f8acd48 100644
--- a/srchenv.c
+++ b/srchenv.c
@@ -4,6 +4,7 @@
 /* strtol() from C standard library (not all compilers find this)  */


+#include <string.h>
 #include <stdio.h>

【讨论】:

  • 如果没有人知道任何替代方案,我可能最终会这样做。
  • @reprogrammer:如果你不等待替代方案,你可以在 5 分钟内完成这项任务。
  • @Ken Bloom:正如我所料,扁平化包的质量不高。我想这就是为什么它没有包含在 TeXLive 发行版中的原因。当我尝试制作包时,出现编译错误(请参阅drop.io/bcwnlwl 的错误)
  • @reprogrammer:有人只需要flatten.lx开头的#include&lt;stdlib.h&gt;。这是一个非常容易解决的问题。
  • @Ken Bloom:我虽然错误是因为缺少包含。但是,因为我在文件中看到了那个包含,所以我拒绝添加它。无论如何,添加包含修复了第一个错误,但引发了另一个错误(请参阅drop.io/k2nr7um)。
【解决方案2】:

或者,您可以使用FLaP。它内联\input\include 指令,并支持使用\includeonly。此外,它会移动图形文件,以便生成的“合并”LaTeX 项目包含在单个平面目录中。支持\graphicspath\includesvg,可处理SVG、EPS、PDF图片。

【讨论】:

    猜你喜欢
    • 2014-07-27
    • 2012-04-19
    • 1970-01-01
    • 2012-01-29
    • 1970-01-01
    • 1970-01-01
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多