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")

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aastex-0.4.0.tar.gz (146.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aastex-0.4.0-py3-none-any.whl (136.7 kB view details)

Uploaded Python 3

File details

Details for the file aastex-0.4.0.tar.gz.

File metadata

  • Download URL: aastex-0.4.0.tar.gz
  • Upload date:
  • Size: 146.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for aastex-0.4.0.tar.gz
Algorithm Hash digest
SHA256 337c8a20f7dc7db702132118a6e9325e4668c5194c539d23b0e54c62123867d4
MD5 9a608fb29b601bac70db989e576c5ca1
BLAKE2b-256 2be2196ae1ced690740e272b180fc87fd6424e97536e0c0db5982815db76643e

See more details on using hashes here.

File details

Details for the file aastex-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: aastex-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 136.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for aastex-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a3358448a28a3acfbd4081302fa99b3a9e8f120b7dc39eb57d4136eb05d95a5f
MD5 4b0b798cd6d4772f9c634bc6350a46a6
BLAKE2b-256 15f2ad88062965e07dfb6f0ecd44e8e368321fe696694e7770dd7edfbeaeea93

See more details on using hashes here.

Release history Release notifications | RSS feed

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page