views:

157

answers:

1

I'm looking a program to recursively inline all \input{} commands in a LaTeX file. By "recursively", I mean doing the inlining iteratively until no \input{} command remains in the final LaTeX file.

I've already come across the flatten package. But, for some reason, my TeXLive distribution doesn't install it. When I execute the command sudo tlmgr show flatten, I get the error message: tlmgr: cannot find flatten. So, I'm looking for alternative tools that are more standard and easier to install.

+5  A: 

Why don't you just download flatten from CTAN (the link you gave in the question) and install it manually?

EDIT: Apply the following patch to fix the build errors.

commit 4d62b79c5145d2b5556487b483d92df797564a18
Author: Ken Bloom <[email protected]>
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>
Ken Bloom
I might end up doing that if no one knows of any alternatives.
reprogrammer
@reprogrammer: You could be done with this task in 5 minutes if you don't wait around for alternatives.
Ken Bloom
@Ken Bloom: As I expected the flatten package is not of high quality. I guess this is why it hasn't been included in the TeXLive distribution. When I try to make the package, I get compile errors (See the errors at http://drop.io/bcwnlwl)
reprogrammer
@reprogrammer: someone just needs to `#include<stdlib.h>` in the at the beginning of `flatten.lx`. It's a very easy fix.
Ken Bloom
@Ken Bloom: I though the error is because of the missing include. But, because I saw that include in the file, I resisted adding it. Anyways, adding that include fixes the first error, but raises another one (See http://drop.io/k2nr7um).
reprogrammer
@reprogrammer: I've edited my answer to give you a patch that fixes it. If you have trouble applying it, let me know your email address, and I can email you either the patch or the fixed code.
Ken Bloom
@Ken Bloom: Thanks for the patch. It made the code compile.
reprogrammer