If the load argument is set to true, the context will load all of the base macros defined in plasTeX. This includes all of the macros used in the standard TeX and LaTeX distributions.
stack of all macro and category code collections currently in the document being processed. The item at index 0 include the global macro set and default category codes.
set the category code for a character in the current scope. char is the character that will have its category code changed. code is the TeX category code (0-15) to change it to.
create a new TeX chardef like \chardef.
name is the name of the command to create.
num is the character number to use.
look through the stack of macros and return the one with the name key . The return value is an instance of the requested macro, not a reference to the macro class. This method allows you to use Python’s dictionary syntax to retrieve the item from the context as shown below.
tex.context['section']
import macros from another context into the global namespace. The argument, context , must be a dictionary of macros.
set the given label to the currently labelable object. An object can only have one label associated with it.
create a new TeX let like \let.
dest is the command sequence to create.
source is the token to set the command sequence equivalent to.
Example
c.let('bgroup', BeginGroup('{'))
imports all of the base macros defined by plasTeX. This includes all of the macros specified by the TeX and LaTeX systems.
loads a language package to configure names such as \figurename, \tablename, etc. See Section 6.5.2 for more information.
language is a string containing the name of the language file to load.
document is the document object being processed.
load an INI formatted package file (see section 4.3 for more information).
tex is the TeX processor to use in parsing the package content
file is the name of the package to load
options is a dictionary containing the options to pass to the package. This generally comes from the optional argument on a \usepackage or \documentclass macro.
The package being loaded by this method can be one of three type: 1) a native LaTeX package, 2) a Python package, or 3) an INI formatted file. The Python version of the package is searched for first. If it is found, it is loaded and an INI version of the package is also loaded if it exists. If there is no Python version, the true LaTeX version of the package is loaded. If there is an INI version of the package in the same directory as the LaTeX version, that file is loaded also.
create a new LaTeX command like \newcommand.
name is the name of the macro to create.
nargs is the number of arguments including optional arguments.
definition is a string containing the macro definition.
opt is a string containing the default optional value.
Examples
c.newcommand('bold', 1, r'\\textbf{#1}') c.newcommand('foo', 2, r'{\\bf #1#2}', opt='myprefix')
create a new counter like \newcounter.
name is the name of the counter to create.
resetby is the counter that, when incremented, will reset the new counter.
initial is the initial value for the counter.
format is the printed format of the counter.
In addition to creating a new counter macro, another macro corresponding to the \thename is created which prints the value of the counter just like in LaTeX.
create a new TeX definition like \def.
name is the name of the definition to create.
args is a string containing the TeX argument profile.
definition is a string containing the macro code to expand when the definition is invoked.
local is a boolean that specifies that the definition should only exist in the local scope. The default value is true.
Examples
c.newdef('bold', '#1', '{\\bf #1}') c.newdef('put', '(#1,#2)#3', '\\dostuff{#1}{#2}{#3}')
create a new LaTeX environment like \newenvironment. This works exactly like the newcommand() method, except that the definition argument is a two element tuple where the first element is a string containing the macro content to expand at the \begin, and the second element is the macro content to expand at the \end.
Example
c.newenvironment('mylist', 0, (r'\\begin{itemize}', r'\\end{itemize}'))
create a new if like \newif. This also creates macros corresponding to \name true and \name false.
a dictionary of LaTeX packages. The keys are the names of the packages. The values are dictionaries containing the options that were specified when the package was loaded.
pop the top scope off of the stack. If obj is specified, continue to pop scopes off of the context stack until the scope that was originally added by obj is found.
add a new scope to the stack. If a macro instance context is specified, the new scope’s namespace is given by that object.
set up a reference for resolution.
obj is the macro object that is doing the referencing.
label is the label of the node that obj is looking for.
If the item that obj is looking for has already been labeled, the idref attribute of obj is set to the abject. Otherwise, the reference is stored away to be resolved later.
set the current set of category codes to the set used for the verbatim environment.