-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.py
44 lines (34 loc) · 1.81 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from pylatgen import *
r = LaTeX_Article()
# You can use the standard maketitle attributes
r.Title = "Example PyLatGen Article"
r.Author = "M. Python"
r.Date = "January 2018"
r.MakeTitle()
# If stuff stops working, or you want more information about the compilation,
# turn on debug mode to show more information.
# r.Debug()
r.AddSection("Introduction")
r.AddParagraph("PyLatGen is an easy way to build up a write up at the same time as the calculation. It has similar features to a simple \LaTeX document.")
# You can add equations
r.AddEquation(r"a^2 = b^2 + c^2", label = "pythagoras_theorem")
# You can use nomenclature
r.AddNomenclature("a", "The long side of a right-angled triangle")
r.AddNomenclature("b", "One of the two shorter sides of a right-angled triangle")
r.AddNomenclature("c", "One of the two shorter sides of a right-angled triangle")
r.AddParagraph(r"Equation \ref{pythagoras_theorem} is an example of an equation. Equations can also have data substituted in from a list of values:")
r.AddEquation(r"a^2 = b^2 + c^2 = #0^2 + #1^2 = #2 + #3 = #4", label = "pythagoras_theorem_filled", subslist = [3, 4, 9, 16, 25])
r.AddParagraph(r"Hash symbols (\#) followed by an integer indicates a substitution.")
# You can add appendices
r.AppendixAddSection("Appendix A", numbered = False)
r.AppendixAddParagraph("Appendices can be added at any point, they will always be at the end of the document.")
# You can add tables too
# Each row of the table is taken in as a python list
headerrow = ["Name", "Job title"]
row1 = ["Alice", "Software Engineer"]
row2 = ["Bob", "Technician"]
row3 = ["Dave", "Sys. admin"]
r.AddTable(headerrow, row1, row2, row3, bold_header = True)
# When you're done, write it out or compile it (or both)
r.Output("report") # No need to add '.tex' to the file name, but it doesn't matter if you do.
r.Compile()