Skip to main content

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.2.0.tar.gz (303.5 kB view details)

Uploaded Source

Built Distribution

compudoc-0.2.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file compudoc-0.2.0.tar.gz.

File metadata

  • Download URL: compudoc-0.2.0.tar.gz
  • Upload date:
  • Size: 303.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for compudoc-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cf09f46690d954cfda5fbe809835496cc2efc33679ec22876788a21d41152dd5
MD5 0c72e6adbe2d3bae1cdcb44fbc636ac2
BLAKE2b-256 6b305b4216cbc9e3411f56da9fa5a8fa19ae1ef7dce93448c97619ba2ee3f892

See more details on using hashes here.

File details

Details for the file compudoc-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: compudoc-0.2.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

Hashes for compudoc-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 79004719a884958b02a7cc1c5f348b55dfcf71ef248a714f7d28f9e953af0443
MD5 2127cd252a15ae04ec24e8d6223c1b2f
BLAKE2b-256 e3684f5517fccb448df0c1c7e3c31f3586d30bb7d130c3fa6bda111e48a3374f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page