latexreport 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- latexreport-0.1.0/CONTRIBUTING.md +65 -0
- latexreport-0.1.0/LICENSE +21 -0
- latexreport-0.1.0/MANIFEST.in +6 -0
- latexreport-0.1.0/PKG-INFO +147 -0
- latexreport-0.1.0/README.md +112 -0
- latexreport-0.1.0/examples/basic.py +45 -0
- latexreport-0.1.0/pyproject.toml +67 -0
- latexreport-0.1.0/setup.cfg +4 -0
- latexreport-0.1.0/src/latexreport/__init__.py +44 -0
- latexreport-0.1.0/src/latexreport/compiler.py +112 -0
- latexreport-0.1.0/src/latexreport/core.py +246 -0
- latexreport-0.1.0/src/latexreport/elements.py +223 -0
- latexreport-0.1.0/src/latexreport/templates.py +133 -0
- latexreport-0.1.0/src/latexreport/themes.py +118 -0
- latexreport-0.1.0/src/latexreport.egg-info/PKG-INFO +147 -0
- latexreport-0.1.0/src/latexreport.egg-info/SOURCES.txt +18 -0
- latexreport-0.1.0/src/latexreport.egg-info/dependency_links.txt +1 -0
- latexreport-0.1.0/src/latexreport.egg-info/requires.txt +11 -0
- latexreport-0.1.0/src/latexreport.egg-info/top_level.txt +1 -0
- latexreport-0.1.0/tests/test_core.py +70 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Contributing to latexreport
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! Here's how to get started.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/aquila1004/latexreport
|
|
9
|
+
cd latexreport
|
|
10
|
+
python -m venv venv
|
|
11
|
+
source venv/bin/activate # or venv\Scripts\activate on Windows
|
|
12
|
+
pip install -e ".[dev]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Development
|
|
16
|
+
|
|
17
|
+
### Run Tests
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pytest # Run all tests
|
|
21
|
+
pytest --cov=src/latexreport # With coverage
|
|
22
|
+
pytest -v # Verbose output
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Code Quality
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
black src tests examples # Format code
|
|
29
|
+
ruff check --fix src tests examples # Linting
|
|
30
|
+
mypy src/latexreport # Type checking
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Before Committing
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# Format + lint + test
|
|
37
|
+
black src tests examples
|
|
38
|
+
ruff check --fix src tests examples
|
|
39
|
+
pytest
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Ideas for Contribution
|
|
43
|
+
|
|
44
|
+
- 📝 Add more themes
|
|
45
|
+
- 🎨 Better color customization
|
|
46
|
+
- 📊 Built-in chart/plot support
|
|
47
|
+
- 📚 Bibliography support (bibtex)
|
|
48
|
+
- 🌍 Multi-language support
|
|
49
|
+
- 📖 More comprehensive documentation
|
|
50
|
+
- 🧪 Better test coverage
|
|
51
|
+
- ⚡ Performance improvements
|
|
52
|
+
|
|
53
|
+
## Pull Request Process
|
|
54
|
+
|
|
55
|
+
1. Fork the repository
|
|
56
|
+
2. Create a feature branch: `git checkout -b feature/your-feature`
|
|
57
|
+
3. Make your changes
|
|
58
|
+
4. Test: `pytest`
|
|
59
|
+
5. Commit: `git commit -m "Add feature: your feature"`
|
|
60
|
+
6. Push: `git push origin feature/your-feature`
|
|
61
|
+
7. Open a Pull Request
|
|
62
|
+
|
|
63
|
+
## Questions?
|
|
64
|
+
|
|
65
|
+
Open an issue on the repository!
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Áquila Oliveira Souza
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: latexreport
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate professional LaTeX reports and PDFs programmatically with Python
|
|
5
|
+
Author-email: Áquila Oliveira Souza <aquilasouza1004@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/aquila1004/latexreport
|
|
8
|
+
Project-URL: Repository, https://github.com/aquila1004/latexreport.git
|
|
9
|
+
Project-URL: Documentation, https://github.com/aquila1004/latexreport#readme
|
|
10
|
+
Project-URL: Issues, https://github.com/aquila1004/latexreport/issues
|
|
11
|
+
Keywords: latex,report,pdf,documentation,automation
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Education
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Office/Business
|
|
21
|
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: matplotlib>=3.7
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
29
|
+
Requires-Dist: black>=23.0; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
31
|
+
Requires-Dist: mypy>=1.0; extra == "dev"
|
|
32
|
+
Provides-Extra: pdf
|
|
33
|
+
Requires-Dist: latexmk>=1.0; extra == "pdf"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# latexreport
|
|
37
|
+
|
|
38
|
+
🚀 Generate professional LaTeX reports and PDFs programmatically with Python.
|
|
39
|
+
|
|
40
|
+
No LaTeX knowledge required — build beautiful documents with simple Python code.
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install latexreport
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
To compile PDFs automatically, also install the LaTeX compiler:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
# Ubuntu/Debian
|
|
52
|
+
sudo apt-get install texlive-latex-base texlive-latex-extra
|
|
53
|
+
|
|
54
|
+
# macOS
|
|
55
|
+
brew install mactex
|
|
56
|
+
|
|
57
|
+
# Windows
|
|
58
|
+
# Download from https://miktex.org/download
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Quick Start
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from latexreport import Report, Section, Figure, Table
|
|
65
|
+
|
|
66
|
+
# Create report
|
|
67
|
+
report = Report(
|
|
68
|
+
title="My Report",
|
|
69
|
+
author="Your Name",
|
|
70
|
+
subtitle="A professional document"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Add content
|
|
74
|
+
report.add_section(Section("Introduction"))
|
|
75
|
+
report.add_text("This is the introduction.")
|
|
76
|
+
|
|
77
|
+
report.add_figure("chart.png", caption="Chart 1", width=0.8)
|
|
78
|
+
|
|
79
|
+
report.add_section(Section("Results"))
|
|
80
|
+
report.add_table(
|
|
81
|
+
data=[[1, 2, 3], [4, 5, 6]],
|
|
82
|
+
columns=["A", "B", "C"],
|
|
83
|
+
caption="Table 1"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
# Export
|
|
87
|
+
report.to_latex("report.tex") # Save LaTeX file
|
|
88
|
+
report.to_pdf("report.pdf") # Compile to PDF
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Features
|
|
92
|
+
|
|
93
|
+
✅ **Simple API** — Pythonic interface for LaTeX
|
|
94
|
+
✅ **Sections & Subsections** — Nested structure support
|
|
95
|
+
✅ **Rich Content** — Text, figures, tables, code blocks, equations
|
|
96
|
+
✅ **Customizable** — Themes, colors, fonts, preamble
|
|
97
|
+
✅ **Auto-Compilation** — Generate PDFs with one method call
|
|
98
|
+
✅ **Cross-References** — Labels, captions, references
|
|
99
|
+
✅ **Extensible** — Add custom LaTeX commands
|
|
100
|
+
|
|
101
|
+
## Examples
|
|
102
|
+
|
|
103
|
+
See [examples/](examples/) directory:
|
|
104
|
+
|
|
105
|
+
- `basic.py` — Simple report with text and figures
|
|
106
|
+
- `academic.py` — Thesis-like document
|
|
107
|
+
- `presentation.py` — Slides with beamer
|
|
108
|
+
- `custom_theme.py` — Custom styling
|
|
109
|
+
|
|
110
|
+
## Documentation
|
|
111
|
+
|
|
112
|
+
- [API Reference](docs/api.md) — Complete class and method documentation
|
|
113
|
+
- [Themes](docs/themes.md) — Available themes and customization
|
|
114
|
+
- [Advanced](docs/advanced.md) — Custom commands, environments, preamble
|
|
115
|
+
- [Troubleshooting](docs/faq.md) — Common issues and solutions
|
|
116
|
+
|
|
117
|
+
## Development
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
git clone https://github.com/aquila1004/latexreport
|
|
121
|
+
cd latexreport
|
|
122
|
+
python -m venv venv
|
|
123
|
+
source venv/bin/activate
|
|
124
|
+
pip install -e ".[dev]"
|
|
125
|
+
pytest
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT License — see [LICENSE](LICENSE)
|
|
131
|
+
|
|
132
|
+
## Contributing
|
|
133
|
+
|
|
134
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
135
|
+
|
|
136
|
+
## Citation
|
|
137
|
+
|
|
138
|
+
If you use latexreport in academic work:
|
|
139
|
+
|
|
140
|
+
```bibtex
|
|
141
|
+
@software{latexreport2024,
|
|
142
|
+
title={latexreport: Python LaTeX Report Generator},
|
|
143
|
+
author={Souza, Áquila},
|
|
144
|
+
year={2024},
|
|
145
|
+
url={https://github.com/aquila1004/latexreport}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# latexreport
|
|
2
|
+
|
|
3
|
+
🚀 Generate professional LaTeX reports and PDFs programmatically with Python.
|
|
4
|
+
|
|
5
|
+
No LaTeX knowledge required — build beautiful documents with simple Python code.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install latexreport
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
To compile PDFs automatically, also install the LaTeX compiler:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Ubuntu/Debian
|
|
17
|
+
sudo apt-get install texlive-latex-base texlive-latex-extra
|
|
18
|
+
|
|
19
|
+
# macOS
|
|
20
|
+
brew install mactex
|
|
21
|
+
|
|
22
|
+
# Windows
|
|
23
|
+
# Download from https://miktex.org/download
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from latexreport import Report, Section, Figure, Table
|
|
30
|
+
|
|
31
|
+
# Create report
|
|
32
|
+
report = Report(
|
|
33
|
+
title="My Report",
|
|
34
|
+
author="Your Name",
|
|
35
|
+
subtitle="A professional document"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Add content
|
|
39
|
+
report.add_section(Section("Introduction"))
|
|
40
|
+
report.add_text("This is the introduction.")
|
|
41
|
+
|
|
42
|
+
report.add_figure("chart.png", caption="Chart 1", width=0.8)
|
|
43
|
+
|
|
44
|
+
report.add_section(Section("Results"))
|
|
45
|
+
report.add_table(
|
|
46
|
+
data=[[1, 2, 3], [4, 5, 6]],
|
|
47
|
+
columns=["A", "B", "C"],
|
|
48
|
+
caption="Table 1"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
# Export
|
|
52
|
+
report.to_latex("report.tex") # Save LaTeX file
|
|
53
|
+
report.to_pdf("report.pdf") # Compile to PDF
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
✅ **Simple API** — Pythonic interface for LaTeX
|
|
59
|
+
✅ **Sections & Subsections** — Nested structure support
|
|
60
|
+
✅ **Rich Content** — Text, figures, tables, code blocks, equations
|
|
61
|
+
✅ **Customizable** — Themes, colors, fonts, preamble
|
|
62
|
+
✅ **Auto-Compilation** — Generate PDFs with one method call
|
|
63
|
+
✅ **Cross-References** — Labels, captions, references
|
|
64
|
+
✅ **Extensible** — Add custom LaTeX commands
|
|
65
|
+
|
|
66
|
+
## Examples
|
|
67
|
+
|
|
68
|
+
See [examples/](examples/) directory:
|
|
69
|
+
|
|
70
|
+
- `basic.py` — Simple report with text and figures
|
|
71
|
+
- `academic.py` — Thesis-like document
|
|
72
|
+
- `presentation.py` — Slides with beamer
|
|
73
|
+
- `custom_theme.py` — Custom styling
|
|
74
|
+
|
|
75
|
+
## Documentation
|
|
76
|
+
|
|
77
|
+
- [API Reference](docs/api.md) — Complete class and method documentation
|
|
78
|
+
- [Themes](docs/themes.md) — Available themes and customization
|
|
79
|
+
- [Advanced](docs/advanced.md) — Custom commands, environments, preamble
|
|
80
|
+
- [Troubleshooting](docs/faq.md) — Common issues and solutions
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/aquila1004/latexreport
|
|
86
|
+
cd latexreport
|
|
87
|
+
python -m venv venv
|
|
88
|
+
source venv/bin/activate
|
|
89
|
+
pip install -e ".[dev]"
|
|
90
|
+
pytest
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT License — see [LICENSE](LICENSE)
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
Contributions welcome! See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
100
|
+
|
|
101
|
+
## Citation
|
|
102
|
+
|
|
103
|
+
If you use latexreport in academic work:
|
|
104
|
+
|
|
105
|
+
```bibtex
|
|
106
|
+
@software{latexreport2024,
|
|
107
|
+
title={latexreport: Python LaTeX Report Generator},
|
|
108
|
+
author={Souza, Áquila},
|
|
109
|
+
year={2024},
|
|
110
|
+
url={https://github.com/aquila1004/latexreport}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Basic example: Create a simple report."""
|
|
2
|
+
|
|
3
|
+
from latexreport import Report, Section, List, ListItem
|
|
4
|
+
|
|
5
|
+
# Create report
|
|
6
|
+
report = Report(
|
|
7
|
+
title="My First Report",
|
|
8
|
+
author="Your Name",
|
|
9
|
+
subtitle="A simple example using latexreport",
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
# Add a section
|
|
13
|
+
report.add_section(Section("Introduction"))
|
|
14
|
+
report.add_text("This is a simple report generated with latexreport.")
|
|
15
|
+
report.add_text("You can add text, figures, tables, and more using Python.")
|
|
16
|
+
|
|
17
|
+
# Add another section
|
|
18
|
+
report.add_section(Section("Features"))
|
|
19
|
+
report.add_text("The library supports:")
|
|
20
|
+
|
|
21
|
+
# Add a list
|
|
22
|
+
features_list = List([
|
|
23
|
+
"Creating structured documents",
|
|
24
|
+
"Adding figures and tables",
|
|
25
|
+
"Code blocks with syntax highlighting",
|
|
26
|
+
"Mathematical formulas",
|
|
27
|
+
"Automatic PDF compilation",
|
|
28
|
+
])
|
|
29
|
+
report.add_list(features_list)
|
|
30
|
+
|
|
31
|
+
# Add section with formulas
|
|
32
|
+
report.add_section(Section("Math Example"))
|
|
33
|
+
report.add_text("Here's a simple equation:")
|
|
34
|
+
report.add_formula("E = mc^2")
|
|
35
|
+
|
|
36
|
+
report.add_text("And an inline formula: " + "$\\sqrt{x^2 + y^2}$")
|
|
37
|
+
|
|
38
|
+
# Export
|
|
39
|
+
print("Generating LaTeX...")
|
|
40
|
+
report.to_latex("output/basic.tex")
|
|
41
|
+
print("✓ LaTeX file: output/basic.tex")
|
|
42
|
+
|
|
43
|
+
print("\nCompiling to PDF...")
|
|
44
|
+
report.to_pdf("output/basic.pdf")
|
|
45
|
+
print("✓ PDF file: output/basic.pdf")
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "latexreport"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Generate professional LaTeX reports and PDFs programmatically with Python"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Áquila Oliveira Souza", email = "aquilasouza1004@gmail.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = ["latex", "report", "pdf", "documentation", "automation"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: Education",
|
|
20
|
+
"License :: OSI Approved :: MIT License",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: Office/Business",
|
|
26
|
+
"Topic :: Text Processing :: Markup :: LaTeX",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
"matplotlib>=3.7",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0",
|
|
36
|
+
"pytest-cov>=4.0",
|
|
37
|
+
"black>=23.0",
|
|
38
|
+
"ruff>=0.1.0",
|
|
39
|
+
"mypy>=1.0",
|
|
40
|
+
]
|
|
41
|
+
pdf = [
|
|
42
|
+
"latexmk>=1.0",
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
[project.urls]
|
|
46
|
+
Homepage = "https://github.com/aquila1004/latexreport"
|
|
47
|
+
Repository = "https://github.com/aquila1004/latexreport.git"
|
|
48
|
+
Documentation = "https://github.com/aquila1004/latexreport#readme"
|
|
49
|
+
Issues = "https://github.com/aquila1004/latexreport/issues"
|
|
50
|
+
|
|
51
|
+
[tool.setuptools]
|
|
52
|
+
packages = ["latexreport"]
|
|
53
|
+
|
|
54
|
+
[tool.setuptools.package-dir]
|
|
55
|
+
"" = "src"
|
|
56
|
+
|
|
57
|
+
[tool.black]
|
|
58
|
+
line-length = 100
|
|
59
|
+
target-version = ["py310"]
|
|
60
|
+
|
|
61
|
+
[tool.ruff]
|
|
62
|
+
line-length = 100
|
|
63
|
+
target-version = "py310"
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
testpaths = ["tests"]
|
|
67
|
+
addopts = "--cov=src/latexreport --cov-report=term-missing"
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""latexreport — Generate professional LaTeX reports and PDFs with Python.
|
|
2
|
+
|
|
3
|
+
A simple, Pythonic interface to create LaTeX documents programmatically.
|
|
4
|
+
|
|
5
|
+
Quick start:
|
|
6
|
+
>>> from latexreport import Report, Section, Figure
|
|
7
|
+
>>> report = Report(title="My Report", author="Author Name")
|
|
8
|
+
>>> report.add_section(Section("Introduction"))
|
|
9
|
+
>>> report.add_text("Hello world!")
|
|
10
|
+
>>> report.to_pdf("output.pdf")
|
|
11
|
+
|
|
12
|
+
Main classes:
|
|
13
|
+
Report: Main document container
|
|
14
|
+
Section: Section with title and content
|
|
15
|
+
Figure: Embedded figure/image
|
|
16
|
+
Table: Data table
|
|
17
|
+
Code: Code block
|
|
18
|
+
Formula: Mathematical equation
|
|
19
|
+
|
|
20
|
+
For full documentation, see: https://github.com/aquila1004/latexreport
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from .core import Report, Section, Content
|
|
24
|
+
from .elements import Figure, Table, Code, Formula, Text, List, ListItem
|
|
25
|
+
from .themes import Theme, THEMES
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
__author__ = "Áquila Oliveira Souza"
|
|
29
|
+
__license__ = "MIT"
|
|
30
|
+
|
|
31
|
+
__all__ = [
|
|
32
|
+
"Report",
|
|
33
|
+
"Section",
|
|
34
|
+
"Content",
|
|
35
|
+
"Figure",
|
|
36
|
+
"Table",
|
|
37
|
+
"Code",
|
|
38
|
+
"Formula",
|
|
39
|
+
"Text",
|
|
40
|
+
"List",
|
|
41
|
+
"ListItem",
|
|
42
|
+
"Theme",
|
|
43
|
+
"THEMES",
|
|
44
|
+
]
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"""LaTeX compilation utilities."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import subprocess
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def compile_to_pdf(
|
|
12
|
+
tex_file: str | Path,
|
|
13
|
+
output_pdf: Optional[str | Path] = None,
|
|
14
|
+
cleanup: bool = True,
|
|
15
|
+
attempts: int = 2,
|
|
16
|
+
) -> Path:
|
|
17
|
+
"""Compile LaTeX file to PDF.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
tex_file: Path to .tex file
|
|
21
|
+
output_pdf: Output PDF path (default: same name as .tex, .pdf extension)
|
|
22
|
+
cleanup: Remove temporary files after compilation
|
|
23
|
+
attempts: Number of compilation attempts (for bibliography, refs, etc)
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
Path to generated PDF file
|
|
27
|
+
|
|
28
|
+
Raises:
|
|
29
|
+
RuntimeError: If compilation fails
|
|
30
|
+
"""
|
|
31
|
+
tex_path = Path(tex_file).resolve()
|
|
32
|
+
if not tex_path.exists():
|
|
33
|
+
raise FileNotFoundError(f"LaTeX file not found: {tex_path}")
|
|
34
|
+
|
|
35
|
+
output_pdf = Path(output_pdf or tex_path.with_suffix(".pdf")).resolve()
|
|
36
|
+
|
|
37
|
+
# Check if pdflatex is available
|
|
38
|
+
try:
|
|
39
|
+
subprocess.run(
|
|
40
|
+
["pdflatex", "--version"],
|
|
41
|
+
capture_output=True,
|
|
42
|
+
check=True,
|
|
43
|
+
timeout=5,
|
|
44
|
+
)
|
|
45
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
46
|
+
raise RuntimeError(
|
|
47
|
+
"pdflatex not found. Install LaTeX:\n"
|
|
48
|
+
" Ubuntu: sudo apt-get install texlive-latex-base\n"
|
|
49
|
+
" macOS: brew install mactex\n"
|
|
50
|
+
" Windows: https://miktex.org/download"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Compile
|
|
54
|
+
output_dir = tex_path.parent
|
|
55
|
+
for attempt in range(attempts):
|
|
56
|
+
try:
|
|
57
|
+
subprocess.run(
|
|
58
|
+
[
|
|
59
|
+
"pdflatex",
|
|
60
|
+
"-interaction=nonstopmode",
|
|
61
|
+
f"-output-directory={output_dir}",
|
|
62
|
+
str(tex_path),
|
|
63
|
+
],
|
|
64
|
+
capture_output=True,
|
|
65
|
+
check=True,
|
|
66
|
+
timeout=60,
|
|
67
|
+
)
|
|
68
|
+
except subprocess.CalledProcessError as e:
|
|
69
|
+
if attempt < attempts - 1:
|
|
70
|
+
continue
|
|
71
|
+
raise RuntimeError(f"LaTeX compilation failed:\n{e.stderr.decode()}") from e
|
|
72
|
+
|
|
73
|
+
# Check output
|
|
74
|
+
temp_pdf = tex_path.with_suffix(".pdf")
|
|
75
|
+
if not temp_pdf.exists():
|
|
76
|
+
raise RuntimeError(f"PDF not generated at {temp_pdf}")
|
|
77
|
+
|
|
78
|
+
# Move to final location if different
|
|
79
|
+
if temp_pdf != output_pdf:
|
|
80
|
+
temp_pdf.rename(output_pdf)
|
|
81
|
+
|
|
82
|
+
# Cleanup temporary files
|
|
83
|
+
if cleanup:
|
|
84
|
+
suffixes_to_remove = [".aux", ".log", ".out", ".toc", ".nav", ".snm"]
|
|
85
|
+
for suffix in suffixes_to_remove:
|
|
86
|
+
temp_file = tex_path.with_suffix(suffix)
|
|
87
|
+
if temp_file.exists():
|
|
88
|
+
temp_file.unlink()
|
|
89
|
+
|
|
90
|
+
print(f"✓ PDF generated: {output_pdf}")
|
|
91
|
+
return output_pdf
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def find_latex_compiler() -> Optional[str]:
|
|
95
|
+
"""Find available LaTeX compiler (pdflatex, xelatex, lualatex).
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
Name of available compiler or None if not found
|
|
99
|
+
"""
|
|
100
|
+
for compiler in ["pdflatex", "xelatex", "lualatex"]:
|
|
101
|
+
try:
|
|
102
|
+
subprocess.run(
|
|
103
|
+
[compiler, "--version"],
|
|
104
|
+
capture_output=True,
|
|
105
|
+
check=True,
|
|
106
|
+
timeout=5,
|
|
107
|
+
)
|
|
108
|
+
return compiler
|
|
109
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
110
|
+
continue
|
|
111
|
+
|
|
112
|
+
return None
|