嗨,我开始使用 pylatex。我尝试使用下面的代码生成 pdf,但只有当我从单词中删除重音符号时才有效información
,但如果我不删除,它会提示错误。
geometry_options = {"tmargin": "1cm", "lmargin": "1cm"}
doc = Document(geometry_options=geometry_options, )
doc.packages.append(Package('booktabs'))
package = Package('babel', options='spanish')
doc.preamble.append(Package('babel', options='spanish'))
doc.preamble.append(Command('title', 'Resultado'))
doc.preamble.append(Command('selectlanguage', 'spanish'))
doc.preamble.append(Command('author', 'N'))
doc.preamble.append(Command('date', NoEscape(r'\today')))
doc.append(NoEscape(r'\maketitle'))
with doc.create(Section('Resultados')):
with doc.create(Subsection('Validaciones')):
doc.append('¿Por que no puedo agregar acentos?')
with doc.create(Subsection('Validaciones de información')):
doc.append('')
doc.generate_pdf('Resultados', clean_tex=False, compiler='pdflatex')
tex = doc.dumps()
错误:
$ python val_format.py
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "val_format.py", line 272, in validation
doc.generate_pdf('Resultados', clean_tex=False, compiler='pdflatex')
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pylatex\document.py", line 247, in generate_pdf
output = subprocess.check_output(command,
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "C:\Users\AppData\Local\Programs\Python\Python38-32\lib\subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pdflatex', '--interaction=nonstopmode', 'D:\\Relations\\Resultados.tex']' returned non-zero exit status 1.
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.6.29)
entering extended mode
(D:/Relations/Resultados.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-06-18>
(C:\Users\ricardo.arias\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cl
s
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo
))
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/base\fontenc.st
y)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/base\inputenc.s
ty)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lm\lmodern.sty)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/base\textcomp.s
ty)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lastpage\lastpa
ge.sty)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/geometry\geomet
ry.sty
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/graphics\keyval
.sty)
(C:\Users\ricardo.arias\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifvtex.
sty
(C:\Users\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.s
ty))
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/geometry\geomet
ry.cfg))
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/booktabs\bookta
bs.sty)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.s
ty
(C:\Users\AppData\Local\Programs\MiKTeX\tex/generic/babel\babel.d
ef
(C:\Users\AppData\Local\Programs\MiKTeX\tex/generic/babel\txtbabe
l.def))
*************************************
* Local config file bblopts.cfg used
*
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/arabi\bblopts.c
fg)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/babel-spanish\s
panish.ldf))
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3bac
kend-pdfmode.def)
No file Resultados.aux.
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lm\t1lmr.fd)
*geometry* driver: auto-detecting
*geometry* detected driver: pdftex
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lm\ot1lmr.fd)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lm\omllmm.fd)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lm\omslmsy.fd)
(C:\Users\AppData\Local\Programs\MiKTeX\tex/latex/lm\omxlmex.fd)
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Underfull \hbox (badness 10000) in paragraph at lines 24--49
Package lastpage Warning: Rerun to get the references right on input line 55.
AED: lastpage setting LastPage
! I can't write on file `Resultados.pdf'.
Please type another file name for output
! Emergency stop.
<to be read again>
\endgroup \set@typeset@protect
l.55 \end{document}
! ==> Fatal error occurred, no output PDF file produced!
Transcript written on Resultados.log.
我怎样才能编写更好的代码并添加任何内容来让我处理重音?谢谢阅读。