2010-05-27 54 views
2

我正在尋找一個程序遞歸內聯LaTeX文件中的所有\input{}命令。通過「遞歸」,我的意思是迭代地進行內聯,直到沒有\input{}命令保留在最終的LaTeX文件中。內聯LaTeX 輸入命令

我已經遇到過flatten包。但是,出於某種原因,我的TeXLive發行版不會安裝它。當我執行命令sudo tlmgr show flatten時,我收到錯誤消息:tlmgr: cannot find flatten。所以,我正在尋找更標準,更易於安裝的替代工具。

+0

我不明白。你想創建一個新文件,其中'\ input {FILE}'的每個實例已經被FILE的內容替換了嗎?這個問題可能會更好地概括並標記'bash'或'shell-scripting'等等(但是,如果你這樣做了,那麼最終可能會有人粘貼「flatten」的內容!) – Geoff 2010-05-27 15:21:14

+0

@Geoff:謝謝爲您的建議。我添加了更多標籤以獲得更多關注。 – reprogrammer 2010-05-27 16:08:07

+1

@Geoff:小心shell腳本建議。 「有些人在遇到問題時想'我知道,我會用正則表達式'。」現在他們有兩個問題。「 - 傑米Zawinski – 2010-05-27 17:51:39

回答

6

爲什麼不直接從CTAN下載平板(您在問題中給出的鏈接)並手動安裝?

編輯:應用以下補丁修復構建錯誤。

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> 
+0

如果沒有人知道任何替代方案,我可能會這樣做。 – reprogrammer 2010-05-27 04:29:35

+2

@reprogrammer:如果您不等待替代品,您可以在5分鐘內完成此任務。 – 2010-05-27 04:33:01

+0

@ Ken Bloom:正如我預料的那樣,拼合包裝的質量並不高。我想這就是爲什麼它沒有被包含在TeXLive發行版中。當我嘗試製作軟件包時,出現編譯錯誤(請參閱http://drop.io/bcwnlwl上的錯誤) – reprogrammer 2010-05-27 16:07:16

0

或者,您可以使用FLaP。它內聯\input\include指令,並支持使用\includeonly。此外,它還會移動圖形文件,以便將生成的「合併」LaTeX項目包含在一個平面目錄中。它支持\graphicspath,\includesvg並處理SVG,EPS和PDF圖像。