JelteF / PyLaTeX

A Python library for creating LaTeX files
https://jeltef.github.io/PyLaTeX/
MIT License
2.26k stars 287 forks source link

how to NoEscape for `\input` commnd #309

Closed yangdaweihit closed 3 years ago

yangdaweihit commented 4 years ago

In the case that there is a tex file to be input like:

% test.tex
This is the content of \LaTeX{}

I want to input it into a file generated by pylatex:

doc = Document()
doc.append(Command('input','test.tex'))

While I got the result:

This is the content of \textbackslash{}LaTeX\{\}\newline%

How could I got the original texts of test.tex? Please guide me. Thank you.

My current solution is like:

with open('sec1.tex') as infile:
    for line in infile:
        doc.append(NoEscape(line))

ADVISE:

Add a function Document.inputfile(file, bNoEscape=True) to faciliate input original tex file.

RaulLima2 commented 3 years ago

Hi, have you try put doc.append(Command('include', 'text')) ?