是否有用于Python的LaTeX“input”或R Markdown子文档的版本?

2024-10-02 20:44:17 发布

您现在位置:Python中文网/ 问答频道 /正文

在LaTeX中,有一个名为“input”(https://en.wikibooks.org/wiki/LaTeX/Modular_Documents#Comparing_the_methods:_input_vs_include)的函数,它允许我包含来自另一个文件的LaTeX代码,基本上作为子文档(https://yihui.name/knitr/demo/child/)。这意味着我基本上可以分解文档,而不必担心这些片段在本地的行为

基本上,我希望能够有一个主文件“printExample.py”,如下所示:

documentFileName = "ABCD"

theCommandImLookingFor "childfile.py"

sampleFuncHere()

“childfile.py”可以是这样的:

def sampleFuncHere():
    print(documentFileName)

“printExample.py”相当于:

documentFileName = "ABCD"

def sampleFuncHere():
    print(documentFileName)

sampleFuncHere()

我试图以类似于LaTeX或R标记的方式使用Python包“Python docx”,但在LaTeX或R标记的子文档中找不到与“input”函数等效的代码


Tags: 文件函数代码文档pyhttpsinputdef