Skip to main content

aastex

tests codecov Black Documentation Status PyPI version

Write AAS journal articles as Python programs.

This library extends PyLaTeX with the pieces of the AASTeX class used by the journals of the American Astronomical Society: titles, authors and their affiliations, acronyms, sections, figures, and bibliographies.

Why write a paper as a program?

In a normal manuscript, the numbers in the prose and the figures beside them are copied from an analysis by hand, and they start drifting from that analysis the moment it changes. Writing the article as a program removes the copying step: figures are generated by the same code that produced the result, and quantities are defined as LaTeX macros computed from Python values, so the text cannot disagree with the analysis behind it.

doc.set_variable_quantity(
    name="speedOfLight",
    value=astropy.constants.c.to(u.km / u.s),
    scientific_notation=True,
)

The prose then refers to \speedOfLight, and the compiled article shows whatever the code computed, correctly formatted with its units.

Installation

aastex is available on PyPI and can be installed using pip:

pip install aastex

Compiling an article also requires a LaTeX installation providing the AASTeX class dependencies. On Debian and Ubuntu:

sudo apt-get install texlive-publishers texlive-science cm-super latexmk

Getting started

import pathlib
import aastex

doc = aastex.Document()
doc.append(aastex.Title("An Interesting Article"))
doc += [
    aastex.Author(
        name="Jane Doe",
        affiliation=aastex.Affiliation("Fancy University"),
        email="jane.doe@fancy.edu",
    )
]

section = aastex.Section("Introduction")
section.append("Some text.")
doc.append(section)

doc.generate_pdf(pathlib.Path("an_interesting_article"))

The documentation walks through a complete example that adds figures, acronyms, computed variables, and a bibliography.

What the library provides

  • Document — the article itself. generate_pdf() writes the .tex file, saves every figure beside it, copies in the AASTeX class and bibliography style, and compiles the result.
  • Title, Author, Affiliation, Abstract, Section — the parts of a manuscript, which can be referenced from the prose by formatting them into a string, so section and figure numbers are never written by hand.
  • Figure, FigureStar, Fig, Gridline — figures built directly from matplotlib figures via add_fig(), or from existing image files via add_image().
  • Variable — a numeric value from the analysis, exposed to the prose as a LaTeX macro.
  • Acronym — an acronym that expands on first use and is abbreviated afterwards.
  • Bibliography — the reference list, from a BibTeX file.

Preparing a submission

The AAS submission system requires every file of a manuscript at the same directory level, since it cannot parse subdirectories. Document.generate_archive() compiles the article and collects the .tex file, the .bbl file required by the AAS conversion software, the class and bibliography style files, and every figure into a flat archive ready to upload:

doc.generate_archive(pathlib.Path("an_interesting_article"), bibliography="sources.bib")

Metadata

Release files for aastex 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aastex 0.6.0
File Size Uploaded
aastex-0.6.0.tar.gz 153.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aastex 0.6.0
File Interpreter ABI Platform
aastex-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 297.7 kB

Release files / aastex-0.6.0.tar.gz

Download URL aastex-0.6.0.tar.gz
Size 153.7 kB
Tags Source
SHA-256 checksum
How to use checksums
fb2a9768e568ae0cea4b22aa55a68af0fea92c3348f9bbf8544b8ba8add8330a
BLAKE2b-256 checksum
How to use checksums
527bde7f20cdabc141d23d7b1add8a4a7a65fad9ca6073e155453919eeacca02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / aastex-0.6.0-py3-none-any.whl

Download URL aastex-0.6.0-py3-none-any.whl
Size 144.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0e6e8606a08d0ac0e77da3d22b3d799c7167afdf9b430e9f987a84a0be7237bc
BLAKE2b-256 checksum
How to use checksums
038e344ecdd9d174a1f46ccadf2a122b2700530109ab1fc3e8112caebacd8635
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page