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")
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aastex-0.5.0.tar.gz.
File metadata
- Download URL: aastex-0.5.0.tar.gz
- Upload date:
- Size: 148.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6c2bf807356b99e8258eed6f895c31fb21634854bdeb1b19d9dab184dd5b1159
|
|
| MD5 |
f934b3c9ab635b13aab810f7cdf15b25
|
|
| BLAKE2b-256 |
e3ba56e32afa88ee1cbfc1ffbbc2c8e27018246dc0082b45ec889f915ad35467
|
File details
Details for the file aastex-0.5.0-py3-none-any.whl.
File metadata
- Download URL: aastex-0.5.0-py3-none-any.whl
- Upload date:
- Size: 138.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8fe0e4f26b946eec9ef12c99325a278e2cf1914a804fc387daebfada6329c74
|
|
| MD5 |
2768472e898243051e9c99245cf51226
|
|
| BLAKE2b-256 |
ab6e520545fdd880a692dda78a77d1a24ddc6950464e094c9c56e1e51f1ee4d9
|