Add python calculations to your LaTeX and Markdown documents.
Project description
compudoc
Add the power of python to your LaTeX and Markdown documents.
Examples
Python code is embedded in your document's comments. Code blocks within comment blocks are marked with a '{{{' and '}}}' line. Here is a LaTeX exmaple.
% arara: pdflatex
% start with vim --server latex %
\documentclass[]{article}
\usepackage{siunitx}
\usepackage{physics}
\usepackage{graphicx}
\usepackage{fullpage}
\author{C.D. Clark III}
\title{On...}
\begin{document}
\maketitle
% {{{ {}
% import pint
% ureg = pint.UnitRegistry()
% Q_ = ureg.Quantity
% }}}
Laser exposures are characterized by a power ($\Phi$), energy ($Q$), radiant exposure ($H$),
or irradiance ($E$). Each of these four radiometric quantities are related to each other
through the exposure area and duration.
% {{{ {}
% power = Q_(100,'mW')
% duration = Q_(0.25,'s')
% energy = (power * duration).to("mJ")
% }}}
For example, if a laser outputs a power of {{'{:Lx}'.format(power)}} for a
duration of {{duration | fmt("Lx")}}, then the energy delivered during the
exposure will be {{energy | fmt("Lx")}}.
\end{document}
Save this to a file named main.tex
and run
$ compudoc main.tex
This will create a file named main-rendered.tex
with the following content
% arara: pdflatex
% start with vim --server latex %
\documentclass[]{article}
\usepackage{siunitx}
\usepackage{physics}
\usepackage{graphicx}
\usepackage{fullpage}
\author{C.D. Clark III}
\title{On...}
\begin{document}
\maketitle
% {{{ {}
% import pint
% ureg = pint.UnitRegistry()
% Q_ = ureg.Quantity
% }}}
Laser exposures are characterized by a power ($\Phi$), energy ($Q$), radiant exposure ($H$),
or irradiance ($E$). Each of these four radiometric quantities are related to each other
through the exposure area and duration.
% {{{ {}
% power = Q_(100,'mW')
% duration = Q_(0.25,'s')
% energy = (power * duration).to("mJ")
% }}}
For example, if a laser outputs a power of \SI[]{100}{\milli\watt} for a
duration of \SI[]{0.25}{\second}, then the energy delivered during the
exposure will be \SI[]{25.0}{\milli\joule}.
\end{document}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
compudoc-0.3.0.tar.gz
(303.6 kB
view details)
Built Distribution
File details
Details for the file compudoc-0.3.0.tar.gz
.
File metadata
- Download URL: compudoc-0.3.0.tar.gz
- Upload date:
- Size: 303.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b9b1b8da50d0b105f58c599bf1aceeed0c2d307d202511a96f724adde14553d |
|
MD5 | bd1d184c7dd96a696d270670bfc4cc57 |
|
BLAKE2b-256 | ad5ed50a4a99e5b6b895990bcd41728ab76b816f18efa0f156bee4f5693af1be |
File details
Details for the file compudoc-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: compudoc-0.3.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2fb5bea36004e2d09668f1e57bd45d3a754dd48c9bc3ba223807a3711ddd39b7 |
|
MD5 | 361f07c6e3a4ebc033bab765e1db3f8d |
|
BLAKE2b-256 | 64568ff22f4cd148eef4f00ae5bb12e86128c54ffc3ad499d6bf2f06282342bc |