Output: LaTeX, text, documents and citations¶
JacoPy renders expressions, proof chains and theorems as LaTeX, as plain text, in the terminal and in Jupyter, and can write a complete LaTeX document for a theorem. It also keeps an APA-style bibliography of the works its definitions come from. This page shows the calls.
Setup¶
import jacopy
import jacopy.central.tangent as tg
reg = jacopy.PropertyRegistry()
f, h = jacopy.functions("f h", registry=reg)
X, Y = jacopy.vector_fields("X Y")
alpha, beta = jacopy.forms("alpha beta", degree=1)
(omega,) = jacopy.forms("omega", degree=2)
book = jacopy.TheoremBook()
tg.register_cartan_theorems(book, alpha, X, Y, f, registry=reg)
from jacopy.display.latex import chain_to_latex, theorem_to_latex
from jacopy.display.ascii import step_to_ascii, chain_to_ascii
import jacopy.bibliography as bib
expr = jacopy.lie_derivative(X)(omega) # an expression
chain = tg.prove_cartan_magic_on_functions(X, f, registry=reg) # a proof chain
thm = book.get("cartan_magic_on_functions") # a theorem
There are two different functions called cite. jacopy.cite() adds a theorem to
an engine as a rule (see Running proofs); jacopy.bibliography.cite
builds a literature citation (below).
Expressions¶
Output |
In code |
Result |
|---|---|---|
LaTeX string |
|
|
plain text |
|
|
print to the terminal |
|
prints the text form |
display object |
|
rendered as math in Jupyter; a LaTeX string in the terminal |
print(jacopy.to_latex(expr))
print(jacopy.to_ascii(expr))
jacopy.print_expr(expr)
print(jacopy.display_expr(expr))
\mathcal{L}_{X}\!\left(\omega\right)
L_X(omega)
L_X(omega)
\mathcal{L}_{X}\!\left(\omega\right)
See jacopy.to_latex(), jacopy.to_ascii(), jacopy.print_expr()
and jacopy.display_expr().
Proof chains and theorems¶
Output |
In code |
Result |
|---|---|---|
chain as text |
|
one line per step: rule, provenance, before and after |
one step as text |
|
a single line |
chain as a tree in the terminal |
|
printed |
chain in Jupyter |
|
a LaTeX display object |
theorem in Jupyter |
|
an HTML display object |
chain as LaTeX |
|
a LaTeX string |
theorem as LaTeX |
|
a LaTeX string |
stand-alone LaTeX document |
|
a complete |
print(chain_to_ascii(chain).splitlines()[0][:72])
print(step_to_ascii(chain.steps[0])[:60])
dc = jacopy.display_chain(chain)
dt = jacopy.display_theorem(thm)
print(type(dc).__name__, type(dt).__name__)
[intrinsic L (Cartan-TM): L_X f = ρ(X)(f), L_X Y = [X,Y], (L_X ω)(Y…) =
[intrinsic L (Cartan-TM): L_X f = ρ(X)(f), L_X Y = [X,Y], (L
LatexDisplay HtmlDisplay
A theorem can be written to a LaTeX file and compiled with pdflatex:
tex_chain = chain_to_latex(chain)
tex_thm = theorem_to_latex(thm)
doc = jacopy.theorem_to_latex_document(thm, author="A. Author")
print(doc.splitlines()[0])
\documentclass{article}
with open("cartan.tex", "w") as fh:
fh.write(doc) # then: pdflatex cartan.tex
See jacopy.display_chain(), jacopy.display_theorem() and
jacopy.theorem_to_latex_document().
Bibliography and citations¶
jacopy.bibliography holds the references of the works JacoPy’s definitions and theorems
follow (the list is reproduced in the bibliography).
Purpose |
In code |
Result |
|---|---|---|
full APA reference |
|
a string |
citation with a locator |
|
a |
in-text form |
|
|
sources cited by a chain |
|
the references attached to the rules used |
print(bib.apa_reference("DereliDogan2020")[:60])
c = bib.cite("DereliDogan2020", "Definition 3.10")
print(bib.in_text(c), "|", c.author_year())
print(len(bib.chain_sources(chain.steps)), "sources in this chain")
Dereli, T., & Doğan, K. (2020). Metric-connection geometries
(Dereli & Doğan, 2020, Definition 3.10) | Dereli & Doğan, 2020
0 sources in this chain
Rendering options¶
The renderers share a few keyword options. All of them are keyword-only and change only the output, never the chain. The full list is on the Common parameters and settings page.
Keyword |
Accepted by |
Default |
Effect |
|---|---|---|---|
|
|
|
|
|
text and terminal renderers; LaTeX renderers |
|
how many levels of sub-steps are shown; LaTeX shows top-level steps only unless you raise it |
|
|
|
show only the first steps and end with a “more steps” row |
|
|
|
|
|
|
|
append the reference list of the works the rules cite; in a document |
|
|
|
include the proof transcript after the statement |
|
|
|
|
from jacopy.central.algebroid import algebroid
from jacopy.central.algebroid.theorems import prove_anchor_morphism
E = algebroid("E", declare=("leibniz",))
u, v = E.sections("u v")
ach, _ = prove_anchor_morphism(E, u, v, f, registry=reg) # a chain whose rules cite sources
for mode in ("full", "summary", "compact"):
print(mode, len(chain_to_ascii(chain, verbosity=mode)), "characters")
print(chain_to_latex(chain, max_steps=2).count(r"\vdots"), "ellipsis row")
print(chain_to_latex(ach, cite_style="biblatex").count(r"\parencites") > 0)
print(chain_to_ascii(ach, references=True).splitlines()[-1][:60])
print(len(theorem_to_latex(thm, with_proof=False)) < len(theorem_to_latex(thm)))
print(bib.in_text(c, "latex"))
full 1060 characters
summary 554 characters
compact 453 characters
1 ellipsis row
True
Dereli, T., & Doğan, K. (2020). Metric-connection geometries
True
(Dereli \& Do\u{g}an, 2020, Definition 3.10)