Latex called "Lay-tech" is a documentation system for high quality documentation. It is mainly used for the preparation of technical or scientific papers, but can be used for almost all forms of publication. Latex is not a word processor like MS Word or LibreOffice Writer. Instead, Latex encourages authors not to worry about the appearance of their documents, but to focus on getting the right content. For example, consider the following document:
This article explains the use of pylatex module Python.Engineering October 2018
To create this in most word processors, the author would have to decide which layout to use, so would choose (say) 18pt Helvetica
for the title, 12pt Times Roman
for the name, and so on. As a result, the author spends time developing the document. Latex is based on the idea that it allows authors to start writing a document and leave it to the document designers to develop it. So in Latex you could enter the above document as:
documentclass {article} itle {This article explains use of pylatex module} author {GeeksforGeeks} date {October 2018} egin {document} maketitle Continue reading end {document}
Latex document layout:
There are two main parts of a latex document:
Preamble :
- Preamble — this is the first part of the latex file.
- It contains detailed information about the document such as document class, author name, title, etc.
Body:
- Sections, tables, mathematical equations, graphs, etc. may be included in the body of a latex document.
- All document content is inside & # 39 ; / begin {document} & # 39; and & # 39; / end {document} & # 39;
Some features of latex:
- Preparation of journal articles, technical reports, technical or non-technical books, and slide presentations.
- This provides better control over large documents containing sections, links, tables, and figures.
- This can also be useful to prepare documents containing complex mathematical formulas.
- The generation of bibliographies and indexes is automatic in LaTeX.
- It also provides multilingual typing support.
- To latex document we can also add graphics, illustration and process or spot color.
- PostScript or metaphone fonts are also possible in LaTeX.
Sample LaTeX document:
Example 1: In this example we are shaping a plain latex so that from latex we use the simple input format we used in latex.
|
Output:
Example 2: In this example, we used the subsection label to form latex.
|
Output:
What is Pylatex:
PyLaTeX — it is a Python library for creating and compiling latex documents. The goal of this library is to be simple, but also to provide an extensible interface between Python and latex.
Some features of pylatex:
- We can access all LaTeX features in Python using this module
- We can create documents with fewer lines of code
- Since python is a high-level language, it is easier to write code for pylatex in python compared to LaTeX
- In the above LaTeX code, you must have seen that in order to get equations we need to compute the values ​​and then enter them into the LaTeX document, but with the added python functionality to do arithmetic operations it is much easier to prepare the documents
Create a Pylatex document:
- Install MikTeX and the pylatex module on your system and import it into Python code.
To install MikTeX on your system, follow the link:https://miktex.org/download
To install pylatex on a Windows operating system, enter the following command at the command line:
python -m pip install pylatex
- Create a document to import a document class from the pylatex module. There are different types of documents in latex: article, report, letter, etc. To create a document of type article, create an object of the Document class from latex and pass & # 39; article & # 39;
doc = Document (documentclass = ’article’)
- To add the necessary changes to the document, such as styling or formatting, import the classes required in the python code from pylatex. To add various utilities to a latex document using pylatex, the following way is possible
from pylatex import Document, Section, Subsection from pylatex.utils import italic, bold
- To generate a PDF document file, call the generate_pdf method of the Document class using an object of the Document class, and be sure to pass the pdf document name in its argument this way.
doc.generate_pdf ("Demo_article")
Pylatex example:
Code 1:
|
Output:
Code 2:
How can I make a time delay in Python? 5 answers I would like to know how to put a time delay in a Python script. Answer #1 Here is another example where something is run approximately once a minute: Answer #2 You can use the How to delete a file or folder in Python? 5 answers How do I delete a file or folder in Python? Answer #1 Latest questions |