sympytex 0.3.3__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.
- sympytex-0.3.3/MANIFEST.in +10 -0
- sympytex-0.3.3/Makefile +78 -0
- sympytex-0.3.3/PKG-INFO +157 -0
- sympytex-0.3.3/README.md +137 -0
- sympytex-0.3.3/TODO +3 -0
- sympytex-0.3.3/example.tex +110 -0
- sympytex-0.3.3/gfplot_minimal.tex +45 -0
- sympytex-0.3.3/pyproject.toml +43 -0
- sympytex-0.3.3/setup.cfg +4 -0
- sympytex-0.3.3/src/sympytex/__init__.py +143 -0
- sympytex-0.3.3/src/sympytex/__main__.py +6 -0
- sympytex-0.3.3/src/sympytex/cli.py +83 -0
- sympytex-0.3.3/src/sympytex/data/sympytex.sty +151 -0
- sympytex-0.3.3/src/sympytex.egg-info/PKG-INFO +157 -0
- sympytex-0.3.3/src/sympytex.egg-info/SOURCES.txt +21 -0
- sympytex-0.3.3/src/sympytex.egg-info/dependency_links.txt +1 -0
- sympytex-0.3.3/src/sympytex.egg-info/entry_points.txt +2 -0
- sympytex-0.3.3/src/sympytex.egg-info/requires.txt +4 -0
- sympytex-0.3.3/src/sympytex.egg-info/top_level.txt +1 -0
- sympytex-0.3.3/sympytex.py +148 -0
- sympytex-0.3.3/sympytex.sty +151 -0
- sympytex-0.3.3/sympytexpackage.dtx +1337 -0
- sympytex-0.3.3/sympytexpackage.ins +95 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# The LaTeX sources and examples travel with the sdist so the package
|
|
2
|
+
# can be rebuilt from its dtx source of truth.
|
|
3
|
+
include sympytexpackage.dtx
|
|
4
|
+
include sympytexpackage.ins
|
|
5
|
+
include sympytex.sty
|
|
6
|
+
include sympytex.py
|
|
7
|
+
include Makefile
|
|
8
|
+
include TODO
|
|
9
|
+
include example.tex
|
|
10
|
+
include gfplot_minimal.tex
|
sympytex-0.3.3/Makefile
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Copyright (C) 2009-2014 by Tim Molteno <tim@physics.otago.ac.nz>
|
|
2
|
+
#
|
|
3
|
+
# This file may be redistributed and/or
|
|
4
|
+
# modified under the terms of the GNU General Public License as
|
|
5
|
+
# published by the Free Software Foundation, either version 2 of the
|
|
6
|
+
# License, or (at your option) any later version. To view a copy of this
|
|
7
|
+
# license, see http://www.gnu.org/licenses/ or send a letter to
|
|
8
|
+
# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
9
|
+
# Boston, MA 02110-1301, USA.
|
|
10
|
+
|
|
11
|
+
# To create everything necessary to use the SympyTeX package, type
|
|
12
|
+
#
|
|
13
|
+
# make all
|
|
14
|
+
# and the files sympytex.sty and sympytex.py will be created
|
|
15
|
+
#
|
|
16
|
+
# Requires makecmds.sty, for Debian-based distributions try
|
|
17
|
+
# aptitude install texlive-latex-extra python3-matplotlib
|
|
18
|
+
#
|
|
19
|
+
# SympyTeX requires Python 3, with sympy and matplotlib installed:
|
|
20
|
+
#
|
|
21
|
+
# aptitude install python3 python3-sympy python3-matplotlib
|
|
22
|
+
PYTHON=python3
|
|
23
|
+
|
|
24
|
+
all: clean
|
|
25
|
+
latex sympytexpackage.ins
|
|
26
|
+
|
|
27
|
+
docs:
|
|
28
|
+
rm -f *.sout
|
|
29
|
+
pdflatex -interaction=nonstopmode sympytexpackage.dtx
|
|
30
|
+
mkindex sympytexpackage.idx
|
|
31
|
+
${PYTHON} sympytexpackage.sympy
|
|
32
|
+
pdflatex -interaction=nonstopmode sympytexpackage.dtx
|
|
33
|
+
|
|
34
|
+
# This builds the example document. The example uses matplotlib (aptitude install python3-matplotlib)
|
|
35
|
+
test:
|
|
36
|
+
pdflatex -interaction=nonstopmode example.tex
|
|
37
|
+
${PYTHON} example.sympy
|
|
38
|
+
pdflatex -interaction=nonstopmode example.tex
|
|
39
|
+
|
|
40
|
+
# Copy the docstrip-generated files into the installable Python package
|
|
41
|
+
# in src/sympytex/. Run this after every change to sympytexpackage.dtx.
|
|
42
|
+
sync-package: all
|
|
43
|
+
${PYTHON} tools/sync_package.py
|
|
44
|
+
|
|
45
|
+
# Build the PyPI sdist and wheel (requires: pip install build).
|
|
46
|
+
package: sync-package
|
|
47
|
+
${PYTHON} -m build
|
|
48
|
+
|
|
49
|
+
ctan:
|
|
50
|
+
cp README.md README
|
|
51
|
+
/home/tim/Downloads/ctan/scripts/ctanify/ctanify sympytexpackage.ins README sympytexpackage.pdf example.pdf
|
|
52
|
+
|
|
53
|
+
clean:
|
|
54
|
+
rm -f sympytex.* example.s* sympytexpackage.dvi sympytexpackage.aux
|
|
55
|
+
rm -rf sympy-plots-for-*
|
|
56
|
+
|
|
57
|
+
dist:
|
|
58
|
+
tar -cf SympyTeX.tar sympytex.sty sympytex.py sympytexpackage.ins sympytexpackage.dtx example.tex README TODO Makefile
|
|
59
|
+
gzip -9 SympyTeX.tar
|
|
60
|
+
|
|
61
|
+
DOCS=/usr/share/doc/latex-sympytex
|
|
62
|
+
deb: dist
|
|
63
|
+
rm -rf debian/usr
|
|
64
|
+
rm -rf debian/DEBIAN
|
|
65
|
+
mkdir -p debian/usr/share/texmf-texlive/tex/latex/sympytex
|
|
66
|
+
cp sympytex.sty debian/usr/share/texmf-texlive/tex/latex/sympytex
|
|
67
|
+
mkdir -p debian/DEBIAN
|
|
68
|
+
cp debian/control debian/DEBIAN
|
|
69
|
+
mkdir -p debian${DOCS}
|
|
70
|
+
cp debian/copyright debian${DOCS}
|
|
71
|
+
cp example.tex debian${DOCS}
|
|
72
|
+
find ./debian -type d | xargs chmod 755
|
|
73
|
+
fakeroot dpkg-deb --build debian
|
|
74
|
+
mv debian.deb latex-sympytex_1.0-1_all.deb
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
deb2: dist
|
|
78
|
+
dh_make -p latex-sympytex_1.0-1 -e tim@physics.otago.ac.nz -f SympyTeX.tar.gz
|
sympytex-0.3.3/PKG-INFO
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sympytex
|
|
3
|
+
Version: 0.3.3
|
|
4
|
+
Summary: Embed sympy symbolic computation into LaTeX documents
|
|
5
|
+
Author-email: Tim Molteno <tim@physics.otago.ac.nz>
|
|
6
|
+
License-Expression: GPL-2.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/tmolteno/SympyTeX
|
|
8
|
+
Project-URL: Documentation, https://github.com/tmolteno/SympyTeX#readme
|
|
9
|
+
Keywords: latex,sympy,symbolic-math,typesetting
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Science/Research
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
14
|
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: sympy>=1.1
|
|
18
|
+
Provides-Extra: plots
|
|
19
|
+
Requires-Dist: matplotlib; extra == "plots"
|
|
20
|
+
|
|
21
|
+
This is the SympyTeX package. This package allows you to embed symbolic calculations
|
|
22
|
+
and their results into LaTeX documents. SympyTex uses sympy, the symbolic python engine (http://www.sympy.org), to manipulate
|
|
23
|
+
symbolic expressions. Using SympyTeX, sympy code can be embedded into your document, either hidden from view, or as part of the document, and
|
|
24
|
+
sympy expressions can be rendered into LaTeX expressions and included in your document output.
|
|
25
|
+
|
|
26
|
+
## Citing SympyTeX
|
|
27
|
+
|
|
28
|
+
SympyTex was written by Tim Molteno (tim@physics.otago.ac.nz). The best way to cite
|
|
29
|
+
sympytex is:
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Timothy C.A. Molteno, ''SympyTeX: Embedding symbolic computation into LaTeX
|
|
33
|
+
documents'', Electronics Technical Reports No. 2014-1, ISSN 1172-496X, May 2014.
|
|
34
|
+
|
|
35
|
+
====================================================================
|
|
36
|
+
|
|
37
|
+
## Using SympyTex
|
|
38
|
+
|
|
39
|
+
To use SympyTeX, you need the files, sympytex.sty and sympytex.py. These can be either in the current
|
|
40
|
+
directory, or somewhere sensible on your system. See below for instructions on how to build these files.
|
|
41
|
+
|
|
42
|
+
You also need to have installed the Sympy (Symbolic Python) package
|
|
43
|
+
|
|
44
|
+
aptitude install python3-sympy
|
|
45
|
+
|
|
46
|
+
Create a LaTeX document (say mydoc.tex) that uses the sympytex package.
|
|
47
|
+
|
|
48
|
+
\usepackage{sympytex}
|
|
49
|
+
|
|
50
|
+
...
|
|
51
|
+
|
|
52
|
+
\begin{sympyblock}
|
|
53
|
+
x = sympy.Symbol('x')
|
|
54
|
+
h = sympy.integrate(1+x**4,x)
|
|
55
|
+
\end{sympyblock}
|
|
56
|
+
|
|
57
|
+
The integral of $1+x^4$ is also \sympy{sympy.integrate(1+x**4,x)}.
|
|
58
|
+
or you can use a sympy variable, $h = \sympy{h}$
|
|
59
|
+
|
|
60
|
+
Now run:
|
|
61
|
+
|
|
62
|
+
latex mydoc.tex
|
|
63
|
+
python3 mydoc.sympy
|
|
64
|
+
latex mydoc.tex
|
|
65
|
+
|
|
66
|
+
See the include example.tex for more details.
|
|
67
|
+
|
|
68
|
+
====================================================================
|
|
69
|
+
|
|
70
|
+
## Installing from PyPI
|
|
71
|
+
|
|
72
|
+
The Python half of SympyTeX is published on PyPI, so the `sympytex` module
|
|
73
|
+
imported by the generated `.sympy` files can be installed with pip:
|
|
74
|
+
|
|
75
|
+
pip install sympytex
|
|
76
|
+
|
|
77
|
+
This installs the module and a small `sympytex` command. The command can
|
|
78
|
+
put `sympytex.sty` where LaTeX finds it, and run the sympy pass:
|
|
79
|
+
|
|
80
|
+
sympytex install # copy sympytex.sty into TEXMFHOME
|
|
81
|
+
latex mydoc.tex
|
|
82
|
+
sympytex run mydoc.sympy # same as: python3 mydoc.sympy
|
|
83
|
+
latex mydoc.tex
|
|
84
|
+
|
|
85
|
+
If your documents plot matplotlib figures, install the plotting extra:
|
|
86
|
+
|
|
87
|
+
pip install "sympytex[plots]"
|
|
88
|
+
|
|
89
|
+
The style file and the Python module carry their versions with them;
|
|
90
|
+
if the two halves come from different sources and disagree, the sympy
|
|
91
|
+
pass refuses to run and tells you which one to update (set the
|
|
92
|
+
`SYMPYTEX_IGNORE_VERSION` environment variable to override).
|
|
93
|
+
|
|
94
|
+
For developers, the package lives in `src/sympytex/` and is generated
|
|
95
|
+
from this repository's dtx file (the single source of truth): run
|
|
96
|
+
`make sync-package` after editing `sympytexpackage.dtx`, and
|
|
97
|
+
`make package` to build the sdist and wheel.
|
|
98
|
+
|
|
99
|
+
====================================================================
|
|
100
|
+
|
|
101
|
+
## Building the Package
|
|
102
|
+
|
|
103
|
+
### The easy way
|
|
104
|
+
|
|
105
|
+
Use the provided Makefile
|
|
106
|
+
|
|
107
|
+
make
|
|
108
|
+
make test
|
|
109
|
+
|
|
110
|
+
This will build the SympyTeX package, and also create a sample document.
|
|
111
|
+
|
|
112
|
+
### The hard way
|
|
113
|
+
To build the SympyTeX package you will need to install some extra LaTeX
|
|
114
|
+
packages (makecmds.sty)
|
|
115
|
+
|
|
116
|
+
aptitude install texlive-latex-extra
|
|
117
|
+
|
|
118
|
+
Then do:
|
|
119
|
+
|
|
120
|
+
0. Run `latex sympytexpackage.ins'
|
|
121
|
+
|
|
122
|
+
If a PDF file of the documentation wasn't included with this
|
|
123
|
+
distribution of SympyTeX, you will need to build the documentation
|
|
124
|
+
yourself. To do that:
|
|
125
|
+
|
|
126
|
+
1. Run `latex sympytexpackage.dtx'
|
|
127
|
+
2. Run `python3 sympytexpackage.sympy'
|
|
128
|
+
3. Run the indexing commands that the .ins file told you about.
|
|
129
|
+
4. Run `latex sympytexpackage.dtx' again.
|
|
130
|
+
|
|
131
|
+
You can skip step 3 if you don't care about the index. You will need the
|
|
132
|
+
pgf and tikz packages installed to typeset the figures.
|
|
133
|
+
|
|
134
|
+
The file example.tex has, as you likely guessed, a bunch of examples
|
|
135
|
+
showing you how this package works.
|
|
136
|
+
|
|
137
|
+
## Building a debian package
|
|
138
|
+
|
|
139
|
+
This is work-in-progress. But you should be able to build one using
|
|
140
|
+
|
|
141
|
+
make deb
|
|
142
|
+
|
|
143
|
+
## Credits
|
|
144
|
+
|
|
145
|
+
SympyTeX builds on a lot of work by others; in particular the work of
|
|
146
|
+
Dan Drake <ddrake@member.ams.org> who created the sagetex package on which
|
|
147
|
+
sympytex is based. See the "Credits" section
|
|
148
|
+
of the documentation for credits. The source code may be modified and
|
|
149
|
+
distributed under the terms of the GPL, v2 or later; the documentation
|
|
150
|
+
may be modified and distributed under a Creative Commons Attribution -
|
|
151
|
+
Noncommercial - Share Alike 3.0 License. See the "Copying and licenses"
|
|
152
|
+
section of the documentation.
|
|
153
|
+
|
|
154
|
+
Please let me know if you find any bugs or have any ideas for
|
|
155
|
+
improvement!
|
|
156
|
+
|
|
157
|
+
- Tim Molteno <tim@physics.otago.ac.nz>
|
sympytex-0.3.3/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
This is the SympyTeX package. This package allows you to embed symbolic calculations
|
|
2
|
+
and their results into LaTeX documents. SympyTex uses sympy, the symbolic python engine (http://www.sympy.org), to manipulate
|
|
3
|
+
symbolic expressions. Using SympyTeX, sympy code can be embedded into your document, either hidden from view, or as part of the document, and
|
|
4
|
+
sympy expressions can be rendered into LaTeX expressions and included in your document output.
|
|
5
|
+
|
|
6
|
+
## Citing SympyTeX
|
|
7
|
+
|
|
8
|
+
SympyTex was written by Tim Molteno (tim@physics.otago.ac.nz). The best way to cite
|
|
9
|
+
sympytex is:
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
Timothy C.A. Molteno, ''SympyTeX: Embedding symbolic computation into LaTeX
|
|
13
|
+
documents'', Electronics Technical Reports No. 2014-1, ISSN 1172-496X, May 2014.
|
|
14
|
+
|
|
15
|
+
====================================================================
|
|
16
|
+
|
|
17
|
+
## Using SympyTex
|
|
18
|
+
|
|
19
|
+
To use SympyTeX, you need the files, sympytex.sty and sympytex.py. These can be either in the current
|
|
20
|
+
directory, or somewhere sensible on your system. See below for instructions on how to build these files.
|
|
21
|
+
|
|
22
|
+
You also need to have installed the Sympy (Symbolic Python) package
|
|
23
|
+
|
|
24
|
+
aptitude install python3-sympy
|
|
25
|
+
|
|
26
|
+
Create a LaTeX document (say mydoc.tex) that uses the sympytex package.
|
|
27
|
+
|
|
28
|
+
\usepackage{sympytex}
|
|
29
|
+
|
|
30
|
+
...
|
|
31
|
+
|
|
32
|
+
\begin{sympyblock}
|
|
33
|
+
x = sympy.Symbol('x')
|
|
34
|
+
h = sympy.integrate(1+x**4,x)
|
|
35
|
+
\end{sympyblock}
|
|
36
|
+
|
|
37
|
+
The integral of $1+x^4$ is also \sympy{sympy.integrate(1+x**4,x)}.
|
|
38
|
+
or you can use a sympy variable, $h = \sympy{h}$
|
|
39
|
+
|
|
40
|
+
Now run:
|
|
41
|
+
|
|
42
|
+
latex mydoc.tex
|
|
43
|
+
python3 mydoc.sympy
|
|
44
|
+
latex mydoc.tex
|
|
45
|
+
|
|
46
|
+
See the include example.tex for more details.
|
|
47
|
+
|
|
48
|
+
====================================================================
|
|
49
|
+
|
|
50
|
+
## Installing from PyPI
|
|
51
|
+
|
|
52
|
+
The Python half of SympyTeX is published on PyPI, so the `sympytex` module
|
|
53
|
+
imported by the generated `.sympy` files can be installed with pip:
|
|
54
|
+
|
|
55
|
+
pip install sympytex
|
|
56
|
+
|
|
57
|
+
This installs the module and a small `sympytex` command. The command can
|
|
58
|
+
put `sympytex.sty` where LaTeX finds it, and run the sympy pass:
|
|
59
|
+
|
|
60
|
+
sympytex install # copy sympytex.sty into TEXMFHOME
|
|
61
|
+
latex mydoc.tex
|
|
62
|
+
sympytex run mydoc.sympy # same as: python3 mydoc.sympy
|
|
63
|
+
latex mydoc.tex
|
|
64
|
+
|
|
65
|
+
If your documents plot matplotlib figures, install the plotting extra:
|
|
66
|
+
|
|
67
|
+
pip install "sympytex[plots]"
|
|
68
|
+
|
|
69
|
+
The style file and the Python module carry their versions with them;
|
|
70
|
+
if the two halves come from different sources and disagree, the sympy
|
|
71
|
+
pass refuses to run and tells you which one to update (set the
|
|
72
|
+
`SYMPYTEX_IGNORE_VERSION` environment variable to override).
|
|
73
|
+
|
|
74
|
+
For developers, the package lives in `src/sympytex/` and is generated
|
|
75
|
+
from this repository's dtx file (the single source of truth): run
|
|
76
|
+
`make sync-package` after editing `sympytexpackage.dtx`, and
|
|
77
|
+
`make package` to build the sdist and wheel.
|
|
78
|
+
|
|
79
|
+
====================================================================
|
|
80
|
+
|
|
81
|
+
## Building the Package
|
|
82
|
+
|
|
83
|
+
### The easy way
|
|
84
|
+
|
|
85
|
+
Use the provided Makefile
|
|
86
|
+
|
|
87
|
+
make
|
|
88
|
+
make test
|
|
89
|
+
|
|
90
|
+
This will build the SympyTeX package, and also create a sample document.
|
|
91
|
+
|
|
92
|
+
### The hard way
|
|
93
|
+
To build the SympyTeX package you will need to install some extra LaTeX
|
|
94
|
+
packages (makecmds.sty)
|
|
95
|
+
|
|
96
|
+
aptitude install texlive-latex-extra
|
|
97
|
+
|
|
98
|
+
Then do:
|
|
99
|
+
|
|
100
|
+
0. Run `latex sympytexpackage.ins'
|
|
101
|
+
|
|
102
|
+
If a PDF file of the documentation wasn't included with this
|
|
103
|
+
distribution of SympyTeX, you will need to build the documentation
|
|
104
|
+
yourself. To do that:
|
|
105
|
+
|
|
106
|
+
1. Run `latex sympytexpackage.dtx'
|
|
107
|
+
2. Run `python3 sympytexpackage.sympy'
|
|
108
|
+
3. Run the indexing commands that the .ins file told you about.
|
|
109
|
+
4. Run `latex sympytexpackage.dtx' again.
|
|
110
|
+
|
|
111
|
+
You can skip step 3 if you don't care about the index. You will need the
|
|
112
|
+
pgf and tikz packages installed to typeset the figures.
|
|
113
|
+
|
|
114
|
+
The file example.tex has, as you likely guessed, a bunch of examples
|
|
115
|
+
showing you how this package works.
|
|
116
|
+
|
|
117
|
+
## Building a debian package
|
|
118
|
+
|
|
119
|
+
This is work-in-progress. But you should be able to build one using
|
|
120
|
+
|
|
121
|
+
make deb
|
|
122
|
+
|
|
123
|
+
## Credits
|
|
124
|
+
|
|
125
|
+
SympyTeX builds on a lot of work by others; in particular the work of
|
|
126
|
+
Dan Drake <ddrake@member.ams.org> who created the sagetex package on which
|
|
127
|
+
sympytex is based. See the "Credits" section
|
|
128
|
+
of the documentation for credits. The source code may be modified and
|
|
129
|
+
distributed under the terms of the GPL, v2 or later; the documentation
|
|
130
|
+
may be modified and distributed under a Creative Commons Attribution -
|
|
131
|
+
Noncommercial - Share Alike 3.0 License. See the "Copying and licenses"
|
|
132
|
+
section of the documentation.
|
|
133
|
+
|
|
134
|
+
Please let me know if you find any bugs or have any ideas for
|
|
135
|
+
improvement!
|
|
136
|
+
|
|
137
|
+
- Tim Molteno <tim@physics.otago.ac.nz>
|
sympytex-0.3.3/TODO
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
% Copyright (C) 2009-2014 by Tim Molteno <tim@physics.otago.ac.nz>
|
|
2
|
+
%
|
|
3
|
+
% This file may be redistributed and/or
|
|
4
|
+
% modified under the terms of the GNU General Public License as
|
|
5
|
+
% published by the Free Software Foundation, either version 2 of the
|
|
6
|
+
% License, or (at your option) any later version. To view a copy of this
|
|
7
|
+
% license, see http://www.gnu.org/licenses/ or send a letter to
|
|
8
|
+
% the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
9
|
+
% Boston, MA 02110-1301, USA.
|
|
10
|
+
|
|
11
|
+
\documentclass{article}
|
|
12
|
+
\usepackage{amsmath}
|
|
13
|
+
\usepackage{amsfonts}
|
|
14
|
+
\usepackage{amssymb}
|
|
15
|
+
\usepackage{sympytex}
|
|
16
|
+
|
|
17
|
+
\title{SympyTeX example}
|
|
18
|
+
\author{Tim Molteno\thanks{tim@physics.otago.ac.nz}}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
\begin{document}
|
|
22
|
+
|
|
23
|
+
\maketitle
|
|
24
|
+
|
|
25
|
+
\section{Important! Setting up Your \LaTeX environment}
|
|
26
|
+
|
|
27
|
+
To use SympyTeX, you have to run latex (or pdflatex) on your file, then python3, and then latex again.
|
|
28
|
+
\begin{verbatim}
|
|
29
|
+
latex example.tex
|
|
30
|
+
python3 example.sympy
|
|
31
|
+
latex example.tex
|
|
32
|
+
\end{verbatim}
|
|
33
|
+
If you use Kile, or another \LaTeX environment, you can set it up to automatically do the
|
|
34
|
+
sympy python command as part of your build process.
|
|
35
|
+
|
|
36
|
+
\section{Introduction}
|
|
37
|
+
|
|
38
|
+
Using sympy within your \LaTeX document is as easy as $2+2=\sympy{2+2}$.
|
|
39
|
+
|
|
40
|
+
You can write a block, and then use the variables defined later in your code!
|
|
41
|
+
\begin{sympyblock}
|
|
42
|
+
x = sympy.Symbol('x')
|
|
43
|
+
h = sympy.integrate(1+x,x)
|
|
44
|
+
\end{sympyblock}
|
|
45
|
+
The variable $h$, can now be called using {\verb!\sympy{h}!}, and you will get $h = \sympy{h}$.
|
|
46
|
+
Similarly, the integral of $1+x^4$ is $\sympy{sympy.integrate(1+x**4,x)}$.
|
|
47
|
+
|
|
48
|
+
\section{sympyplain}
|
|
49
|
+
|
|
50
|
+
The sympyplain command places the sympy output as text (rather than LaTeX formatted math stuff).
|
|
51
|
+
This is really useful if the output is huge as formulae don't line wrap.
|
|
52
|
+
|
|
53
|
+
The integral of $1+x^4$ is also \sympyplain{sympy.integrate(1+x**4,x)}.
|
|
54
|
+
|
|
55
|
+
\begin{sympyblock}
|
|
56
|
+
from sympy import *
|
|
57
|
+
e = 1/cos(x)
|
|
58
|
+
\end{sympyblock}
|
|
59
|
+
The series expansion is $\sympy{e.series(x, 0, 10)}$.
|
|
60
|
+
|
|
61
|
+
\subsection{Invisibly sympy code}
|
|
62
|
+
|
|
63
|
+
Placing a {\tt sympysilent} block in your code, allows you do do things like define
|
|
64
|
+
symbols without making a mess.
|
|
65
|
+
\begin{sympysilent}
|
|
66
|
+
theta = sympy.Symbol('theta')
|
|
67
|
+
from sympy import *
|
|
68
|
+
def RotationMatrixZ(angle):
|
|
69
|
+
return Matrix([[cos(angle), -sin(angle), 0],[sin(angle), cos(angle),0],[0,0,1]])
|
|
70
|
+
\end{sympysilent}
|
|
71
|
+
The rotation matrix is through an angle $\theta$ around the $z$-axis is
|
|
72
|
+
\[ R(\theta) = \sympy{RotationMatrixZ(theta)}. \]
|
|
73
|
+
|
|
74
|
+
\section{Plotting}
|
|
75
|
+
|
|
76
|
+
Plotting works using the {\tt sympyplot} command. This takes a matplotlib figure as a parameter. Have a look at the example below.
|
|
77
|
+
\begin{sympyblock}
|
|
78
|
+
import matplotlib
|
|
79
|
+
import matplotlib.pyplot as plt
|
|
80
|
+
plt.matplotlib.rc('text', usetex = True)
|
|
81
|
+
import pylab
|
|
82
|
+
import numpy as np
|
|
83
|
+
fig = plt.figure()
|
|
84
|
+
ax = fig.add_subplot(111)
|
|
85
|
+
t = pylab.linspace(0,10,400)
|
|
86
|
+
ax.plot(t, np.sin(t*3), '-',
|
|
87
|
+
t, np.sin(0.3*t**2), '--',
|
|
88
|
+
t, np.cos(t), '-.')
|
|
89
|
+
ax.legend((r'$A^{\omega}$', r'$A^{2\omega}$', r'$A^{3\omega}$'),
|
|
90
|
+
shadow = False, loc = (0.75, 0.1))
|
|
91
|
+
ax.set_xlabel(r'$\gamma_1 + \gamma_2$', {'fontsize' : 20 })
|
|
92
|
+
ax.set_ylabel(r'$A^{n\omega}$ (dB)', {'fontsize' : 20 })
|
|
93
|
+
\end{sympyblock}
|
|
94
|
+
Here we're using matplotlib! So this sympytex package is really not quite named properly.
|
|
95
|
+
|
|
96
|
+
\begin{figure}
|
|
97
|
+
\sympyplot[width=\linewidth]{fig}
|
|
98
|
+
\caption{The graph generated from {\tt \textbackslash sympyplot[width=\textbackslash linewidth]\{fig\}} }
|
|
99
|
+
\end{figure}
|
|
100
|
+
|
|
101
|
+
The syntax is
|
|
102
|
+
{\verb! \sympyplot[<includegraphics opts>][fmt]{figure} !}
|
|
103
|
+
where:
|
|
104
|
+
\begin{itemize}
|
|
105
|
+
\item {\verb!fmt!} can be one of pdf,eps,png,jpg or many more. If it is omitted, then an appropriate choice will be made for you.
|
|
106
|
+
\item {\verb!<figure>!} is a matplotlib figure object
|
|
107
|
+
\end{itemize}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
\end{document}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
\documentclass{article}
|
|
2
|
+
\usepackage{amsmath}
|
|
3
|
+
\usepackage{amsfonts}
|
|
4
|
+
\usepackage{amssymb}
|
|
5
|
+
\usepackage{sympytex}
|
|
6
|
+
|
|
7
|
+
\usepackage{pgfplots}
|
|
8
|
+
|
|
9
|
+
\title{SympyTeX pgfplots example}
|
|
10
|
+
\author{Alexander Steppke}
|
|
11
|
+
|
|
12
|
+
\begin{document}
|
|
13
|
+
|
|
14
|
+
\maketitle
|
|
15
|
+
|
|
16
|
+
\section{Plotting with PGF/TikZ in SympyTeX}
|
|
17
|
+
To plot figures with SympyTeX besides the python matplotlib alternatively the LaTeX package pgfplots can be used. Pgfplots is using the PGF/TikZ package as a graphics backend. The main advantages are the fast output, as we do not need to create any external files and the good integration of pgfplots into LaTeX. A short example is given below.
|
|
18
|
+
|
|
19
|
+
\begin{sympyblock}
|
|
20
|
+
from numpy import linspace, sin
|
|
21
|
+
time = linspace(0,6,200)
|
|
22
|
+
values = sin(3*time)
|
|
23
|
+
coordinates = ""
|
|
24
|
+
for t, v in zip(time, values):
|
|
25
|
+
coordinates = coordinates + '({:.5f}, {:.5f}) '.format(t, v)
|
|
26
|
+
|
|
27
|
+
pgfplot = r"""
|
|
28
|
+
\begin{tikzpicture}
|
|
29
|
+
\begin{axis}[xlabel=Time,ylabel=Amplitude]
|
|
30
|
+
\addplot[color=red,mark=x] coordinates { %s };
|
|
31
|
+
\end{axis}
|
|
32
|
+
\end{tikzpicture}
|
|
33
|
+
""" % (coordinates)
|
|
34
|
+
|
|
35
|
+
\end{sympyblock}
|
|
36
|
+
|
|
37
|
+
After calculating the datapoints we insert them into the string {\verb!pgfplot!} and output the string into our LaTeX document using {\verb!\sympyplain{pgfplot}!} in a figure environment.
|
|
38
|
+
\begin{figure}
|
|
39
|
+
\centering
|
|
40
|
+
\sympyplain{pgfplot}
|
|
41
|
+
\caption{A simple plot with SympyTeX and pgfplots.}
|
|
42
|
+
\end{figure}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
\end{document}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sympytex"
|
|
7
|
+
description = "Embed sympy symbolic computation into LaTeX documents"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "GPL-2.0-or-later"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
authors = [{name = "Tim Molteno", email = "tim@physics.otago.ac.nz"}]
|
|
12
|
+
keywords = ["latex", "sympy", "symbolic-math", "typesetting"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 4 - Beta",
|
|
15
|
+
"Intended Audience :: Science/Research",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
18
|
+
"Topic :: Text Processing :: Markup :: LaTeX",
|
|
19
|
+
]
|
|
20
|
+
dependencies = ["sympy>=1.1"]
|
|
21
|
+
dynamic = ["version"]
|
|
22
|
+
|
|
23
|
+
[project.optional-dependencies]
|
|
24
|
+
plots = ["matplotlib"]
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
sympytex = "sympytex.cli:main"
|
|
28
|
+
|
|
29
|
+
[project.urls]
|
|
30
|
+
Homepage = "https://github.com/tmolteno/SympyTeX"
|
|
31
|
+
Documentation = "https://github.com/tmolteno/SympyTeX#readme"
|
|
32
|
+
|
|
33
|
+
[tool.setuptools]
|
|
34
|
+
package-dir = {"" = "src"}
|
|
35
|
+
|
|
36
|
+
[tool.setuptools.packages.find]
|
|
37
|
+
where = ["src"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
sympytex = ["data/*.sty"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.dynamic]
|
|
43
|
+
version = {attr = "sympytex.__version__"}
|
sympytex-0.3.3/setup.cfg
ADDED