JelteF / PyLaTeX

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

How to to compile .tex file? #362

Open catauggie opened 1 year ago

catauggie commented 1 year ago

Try to launch basic simple example from Jupyter Notebook:

from pylatex import Document, Section, Subsection, Command
from pylatex.utils import italic, NoEscape
import pdflatex

doc = Document('test_limit')
doc.append('a dog')
doc.generate_pdf()
but get an error:

Usage

latexmk [options] [filename]

latexmk: error: no such option: --pdf CalledProcessError: Command '['latexmk', '--pdf', '--interaction=nonstopmode', 'C:\Users\ivan\test_limit.tex']' returned non-zero exit status 2.

how could it be solved?

g-r-a-e-m-e commented 10 months ago

Hello! A bit delayed, but I just tested the following and it appears to work. Hope this helps!

Steps taken

  1. From command line
    $ cd <directory-path>
    $ python3 -m venv venv
    $ source venv/bin/activate
    $ pip install pylatex
    $ pip install pdflatex
    $ nano test.py
  2. Python script for test.py
    
    from pylatex import Document, Section, Subsection, Command
    from pylatex.utils import italic, NoEscape
    from pdflatex import PDFLaTeX 

doc = Document('test_limit') doc.append('a dog') doc.generate_pdf('my-pdf')

3.  Write out and exit nano
4. From command line

$ python3 test.py


It should write out the following .pdf to `<directory-path>`

[my-pdf.pdf](https://github.com/JelteF/PyLaTeX/files/13190668/my-pdf.pdf)
chantran22 commented 10 months ago

I did installing pdflatex but it still get error when running code image

how to solve this problem?