aastex
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.texfile, 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 viaadd_fig(), or from existing image files viaadd_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")
Citation
If you use aastex in your research, please cite it.
The citation metadata is kept in CITATION.cff,
which the "Cite this repository" button on GitHub can export as BibTeX or APA.
Every release of aastex is archived on Zenodo with its own DOI.
The concept DOI, 10.5281/zenodo.23108302,
always resolves to the latest version,
and the Zenodo page lists the DOI of every version.
Please include the version of aastex that you used,
which is given by importlib.metadata.version("aastex").
The BibTeX entry below uses the concept DOI.
To cite a specific version instead,
replace doi with the DOI of that version.
@software{aastex,
author = {Smart, Roy T.},
title = {aastex},
version = {X.Y.Z},
doi = {10.5281/zenodo.23108302},
url = {https://github.com/sun-data/aastex},
}
Metadata
Release files for aastex 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aastex-0.8.0.tar.gz | 160.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aastex-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 308.7 kB
Release files / aastex-0.8.0.tar.gz
| Download URL | aastex-0.8.0.tar.gz |
|---|---|
| Size | 160.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5c6a21a3b23f56216c48e58284ac713fb5e4a9b2eccfd0e9622687e6cf0fc7db
|
|
BLAKE2b-256 checksum How to use checksums |
d6c395a4a04c5721d5b1746288c2cdec44cdddc0d917203de8f5ee019ebe878c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency logRelease files / aastex-0.8.0-py3-none-any.whl
| Download URL | aastex-0.8.0-py3-none-any.whl |
|---|---|
| Size | 148.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6f43b8fb2f71628ccf04ed48ad9d300871ed25ef801ab691ad7237789193731e
|
|
BLAKE2b-256 checksum How to use checksums |
7c4715918f337a68ce21abdf8075d70d4eda7e98646fef45ceab9411b6161b95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.
Transparency log