The publication module contains classes and funtions to assist in preparing papers or other publications with an emphasis on common astronomy journals. The tools here are for use with LaTeX as the actual authoring tools.
Bases: astropysics.publication.TeXNode
A LaTeX command (anything with leading backslash and possible arguments that isn’t an environment)
Parameters: |
|
---|
A list of strings with the text of the optional arguments (arguments enclosed in square brackets)
A list of strings with the text of the required arguments (arguments enclosed in curly braces).
Bases: astropysics.publication.TeXNode
A single-line comment of a TeX File. Note that unlike most
Parameters: |
|
---|
The text of this comment (not including the initial %)
Bases: astropysics.publication.Environment
The abstract environment for this document or None if one does not exist
A dictionary mapping section names to the associated index into
Bases: astropysics.publication.TeXNode
A TeX construct of the form {name{op}[op] content}. Note that declarations terminated by the end command will not be treated as this kind of object.
Parameters: |
|
---|
Whitespace string between the opening brace and the command
Bases: astropysics.publication.TeXNode
A LaTex environment.
Subclassing Subclasses can implement the postParse() method - see the method for syntax. They should also be registered with the registerEnvironment() static method to have them be parsed with the default TeXFile parser. Generally, they should also have a class attribute named name that gives the name of the environment (this name will be automatically used to determine which environments the subclass represents)
Parameters: |
|
---|
Returns a tuple of the registered environments.
The name of this environment.
Registers the provided envclass in the environment registry. Also returns the class to allow use as a decorator.
Parameters: | envclass – The Environment object to be registered. |
---|---|
Raises: |
|
Removes the envclass Environment object from the registered environment list
Parameters: | envclass – The Environment object to be removed, or its associated name. |
---|
Bases: astropysics.publication.Environment
The names of the files (usually .eps) in this figure.
Bases: astropysics.publication.TeXNode
A math environment surrounded by $ symbols or $$ (for display mode)
Parameters: |
|
---|
determines if the MathMode is in display mode ($$) or not ($)
Bases: astropysics.publication.TeXt
A node that stores just a new line. This is always a leaf.
Bases: astropysics.publication.TeXNode
An argument to a macro that is required (i.e. enclosed in square brackets)
Bases: astropysics.publication.TeXNode
The preamble of a TeX File (i.e. everything before egin{document} )
Parameters: |
|
---|
The document class of the tex file as a string
The document class options for the tex file as a comma-seperated string.
Bases: astropysics.publication.TeXNode
An argument to a macro that is required (i.e. enclosed in curly braces)
The text of this argument object
Bases: astropysics.publication.TeXNode
A TeX Document loaded from a file.
Bases: object
An element in the TeX parsing tree. The main shared characteristic is that calling the node will return a string with the combined text.
Subclassing
Subclasses must implement getSelfText() (see docstring for details)
A list of child nodes of this node.
Subclass implementations must return a 2-tuple of strings such that the child text goes in between the tuple elements. Alternatively, it can return a 3-tuple (before,between,after), and the resulting text will be “<beforetext><childtext1><between><childtext2>...<after>”. It can also be None, in which case just the strings from the children will be returned. Otherwise, it can return a string, which will be returned as the full text.
Returns True if this node is a leaf (has no children)
Returns True if this node is a root (has no parent)
The parent of this node in the node tree, or None if this is a root.
Removes this node from the tree.
Parameters: | prunechildren – If True, all the children of this node will be pruned (recursively). This is not strictly necessary, but will speed up garbage collection and probably prevent memory leaks. |
---|
Visits all the nodes in the tree (depth-first) and calls the supplied function on those nodes.
Parameters: | func – The function to call on the nodes - should only accept the node as an argument. |
---|---|
Returns: | A sequence of the return values of the function. If the func returns None, it is not included in the returned list. |
Bases: astropysics.publication.TeXNode
A node that stores generic text. This is always a leaf.
Returns the number of words in this object.
Parameters: | sep – The seperator between words. If None, use any whitespace. |
---|---|
Returns: | The number of words in this TeXt object. |
The text in this object
Bases: astropysics.publication.Command
A special command that allows a single trailing character of any type - used for ‘left{‘ ‘right]’ and similar.
Parameters: |
|
---|
This function takes a string from a TeX document starting with ‘egin’ and ending in ‘end{...}’ and uses it to construct the appropriate Environment object.
Takes a LaTeX file and prepares it for submission to The Astrophysical Journal. This involves the following actions:
- Removes all text after end{document} from the .tex file
- Removes all comments from .tex file.
- Checks that the abstract is within the ApJ word limit and issues a warning if it is not.
- Sets the document class to aastex.
- Converts deluxetable* environments to deluxetable.
- Removes epsscale{?} from all figures
- Makes the directory for the files.
- Renames the figures to the ‘f1.eps’,’f2a.eps’, etc. convention for ApJ, and copies the appropriate files over.
- Copies .bib (or .bbl if no .bib) file if bibliography is present.
- Saves the .tex file as “ms.tex”
- Creates ms.tar.gz file containing the files and places it in the newdir directory.
Parameters: |
|
---|---|
Returns: | (file,dir) where file is the altered TexFile object and dir is the directory used for the publication materials. |
Takes a LaTeX file and prepares it for posting to arXiv. This includes the following actions:
- Removes all text after end{document} from the .tex file
- Removes all comments from .tex file.
- Checks that the abstract is within the ArXiv line limit and issues a warning if it is not (will require abridging during submission).
- Makes the directory for the files.
- Copies over all necessary .eps and/or .pdf files.
- Copies .bbl (or .bib if no .bbl) file if bibliography is present.
- Creates the modified .tex file.
- Creates a .tar.gz file containing the files and places it in the newdir directory.
Parameters: |
|
---|---|
Returns: | (file,dir) where file is the altered TexFile object and dir is the directory used for the publication materials. |
Can be False to hide, True to print, or ‘builtin’ to use the python warnings mechanism
Converts a string into a list of corresponding TeXNode objects.
Parameters: |
|
---|---|
Returns: | A list of TeXNode objects |