A simple library to create latex exam in python
Project description
pytexexam
A simple library for writing and printing exam in Python.
Installation
pip install pytexexam
How to use
import pytexexam.latexexamutil as util
from pytexexam import LatexExamBuilder, ExamExportType
# Create exam builder
builder = LatexExamBuilder()
# You can add preamble here
builder.preamble = util.ams_math_package()
# Exam header
builder.header = "This is a simple header"
# Exam footer
builder.footer = "This is a simple footer"
# You can export exam in tex file or pdf file (need Latex installed)
builder.export_type = ExamExportType.PDF
# Add question
builder.add_question(
question="This is a simple question",
# Answers: This package auto add A, B, C, D ... in answers
answer=["Answer 1", "Answer 2", "Answer 3", "Answer 4"],
# True answer key
true_answer="A",
# present answer in multiple column
answer_column=4,
# Solution of this question
solution="This is solution for this question",
)
# Creste exam, answer and solution!
builder.create_exam("exam1")
builder.create_answer("answer1")
builder.create_solution("solution1")
Documentation
If you want to see all the functions included in this library, you can find it here
Note.
If you use Pycharm, you can enable language injection to get Latex support inside Python script
- Install TeXiFy IDEA.
- Go to Settings -> Editor -> Language Injection and add new rule:
- Language ID: Latex (.tex) sources files
- Places patterns: + pyLiteralExpression()
- Enable it!. Now you get Latex syntax hightlighting inside python string! Yayyy!
(You can also add other pattern, using method in this file: https://github.com/JetBrains/intellij-community/blob/master/python/src/com/jetbrains/python/patterns/PythonPatterns.java)
Contribution.
Contribution are welcome. Create a pull request.
Buy me a coffee.
If you find this project useful, you can buy me coffee through Buy me a coffee
License
Apache License, Version 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pytexexam-2.1.5.tar.gz
(11.0 kB
view hashes)
Built Distribution
pytexexam-2.1.5-py3-none-any.whl
(12.9 kB
view hashes)
Close
Hashes for pytexexam-2.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7753d7fab52421271b1566101c90ecdb4695de9fdda82e496f2af054a7d55368 |
|
MD5 | bad21213cb58d9b5bca0393c5959ff55 |
|
BLAKE2b-256 | b48f4f8a1d7220246c0954613bd8ee68085789801fe0f42bfb017b7f587b502d |