List of fixes¶
Here is a list of all “fixes” that you can apply to your latex document.
Each class corresponds to a fix that you can list in your fixes: section of
your lppconfig.yml file. See How to use latexpp and The lppconfig.yml configuration file.
Arguments indicated in parentheses are provided by corresponding YAML keys in
the lppconfig.yml config file. For instance, the instruction
fixes:
...
- name: 'latexpp.fixes.figures.CopyAndRenameFigs'
config:
# template name for figure output file name
fig_rename: '{fig_counter:02}-{orig_fig_basename}{fig_ext}'
# start at figure # 11
start_fig_counter: 11
...
translates to the fix instantiation (python class):
latexpp.fixes.figures.CopyAndRenameFigs(
fig_rename="{fig_counter:02}-{orig_fig_basename}{fig_ext}",
start_fig_counter=11
)
General document contents & formatting¶
- class latexpp.fixes.input.EvalInput(*, usepackage=None)¶
Evaluate
\inputand\includeroutines by replacing the corresponding instruction by the contents of the included file.The contents of the included file will be processed with the rules that are declared after the EvalInput rule. Any rules that have already been applied do not affect the contents pasted in place of the
\input/\includedirectives.Note
You most likely want to have this rule first in your lppconfig.yml fix list.
Arguments:
usepackage [optional] specify a list of package names (a
\usepackageargument) that import a local package file that is assumed to exist in the current directory. The file contents will be included at the location of the\usepackagecall. For example, setusepacakge=['./mymacros.sty']to replace a call to\usepackage{./mymacros.sty}by the contents ofmymacros.sty(surrounded by\makeatletter ... \makeatother).
- class latexpp.fixes.comments.RemoveComments(leave_percent=True, collapse=True)¶
Remove all LaTeX comments from the latex document.
Arguments:
leave_percent: If True (the default), then a full LaTeX comment is replaced by an empty comment, i.e., a single percent sign and whatever whitespace followed the comment (the whitespace is anyways ignored by LaTeX). If False, then the comment and following whitespace is removed entirely.
Expanding custom macros¶
- class latexpp.fixes.newcommand.Expand(*, leave_newcommand=False, newcommand_cmds=None, macro_blacklist_patterns=None, environment_blacklist_patterns=None, envbody_begin='{', envbody_end='}')¶
Detect custom macro and environment definitions in the preamble and apply them throughout the document.
Warning
This fix doesn’t seem to work reliably with my new revamped pylatexenc 3(alpha) because of the new way of handling parsing state changes. I need to fix this fix!
This fix detects custom macros and environments, for instance:
\newcommand\calE{\mathcal{E}} \newcommand\mycomments[1]{\textcolor{red}{#1}} \newcommand\myket[2][\big]{#1|{#2}#1\rangle} % \ket{\psi}, \ket[\Big]{\psi} \newenvironment{boldtext}{\bfseries}{}
This fix then detects their use throughout the LaTeX document and replaces them with their respective substitutions. Macro and environment arguments are processed as you would expect.
By default, the corresponding
\newcommandinstructions are removed from the preamble. If you’d like to keep them even though they have been substituted throughout the document, specify leave_newcommand=True.You can blacklist some macro name patterns and environment name patterns, so that any macro or environment whose name matches a pattern does not get expanded (and its definition is not removed from the preamble). Use the arguments macro_blacklist_patterns and environment_blacklist_patterns for this.
By default, the instructions
\newcommandand\newenvironmentare detected, while the instructions\renewcommand,\providecommand,\renewenvironmentare ignored. If you would like to also replace commands re-defined with those instructions, specify newcommand_cmds (see below).Note
The rationale for not substituting commands defined with
\renewcommandand\providecommand(and same for environments) is that such commands are often used to redefined LaTeX special commands, such as counters or formatting instructions. For instance:\renewcommand{\thepage}{- \roman{page} -} % page numbering format \renewcommand{\familydefault}{\sfdefault} % sans serif font \providecommand{\selectlanguage}[1]{} % babel dummy drop-in
These (re-)defined commands should generally not be substituted by this fix, because they are not used in the document main text but rather, they are used by the LaTeX engine. Especially, if we removed their (re-)definition their effect would disappear entirely (page numbers would revert to defaults, etc.). This is certainly not the intended effect.
Warning
If you opt to add
renewcommandand/orprovidecommandto the argument newcommand_cmds, be aware that they are treated exactly like\newcommand. That is, they do not check whether the macro is already defined (latexpp cannot know if a macro was defined somewhere deep in a package). In particular,\providecommandalways defines the command if this command is enabled via newcommand_cmds.When substituting environments, the full environment is further enclosed within a LaTeX group delimited by braces ‘{’ … ‘}’ (this is because LaTeX actually does create a TeX group for the environment contents). But you can change this if you like using the arguments envbody_begin and envbody_end.
Arguments:
leave_newcommand: Set this to True to leave all macro and environment definition instructions (e.g.,
\newcommand) in the preamble even if we substituted their replacements throughout the document. If False (the default), then we remove macro and environment definitions in the preamble for which we have carried out substitutions throughout the document.Definitions of blacklisted macros/environments and to definitions using instructions that are not in newcommand_cmds are always left in place, regardless of the leave_newcommand argument.
newcommand_cmds: The type of LaTeX command definition instructions to pay attention to. This should be a list containing one or more elements in (‘newcommand’, ‘renewcommand’, ‘providecommand’, ‘newenvironment’, ‘renewenvironment’)
(In the future, I might add support for other definition instructions such as
\DeclareRobustCommand, or\DeclarePairedDelimiter[from the mathtools package]. Adding support for\defwould be more involved, let’s see.)By default, only
\newcommandand\newenvironmentare observed. (See rationale and warning above for ignoring\renewcommandetc. by default)macro_blacklist_patterns, environment_blacklist_patterns: These arguments may be set to a list of regular expressions that specify which macro definitions and environment definitions should not be acted upon by this fix. Any regular expressions recognized by python’s re module may be employed. If a macro (respectively an environment) matches any of the patterns in the respective blacklist, then they are left unchanged in the document and the definitions are left in the preamble unaltered.
For instance, if you use the fix configuration:
- name: 'latexpp.fix.newcommand' config: newcommand_cmds: ['newcommand', 'renewcommand', 'newenvironment'] macro_blacklist_patterns: ['^the', 'blablabla$']
then instructions such as
\renewcommand{\theequation}{\roman{equation}}(or any definition of a macro whose name starts with “the” or that ends with “blablabla”) would be left as-is in the output, and similarly any occurrences of\theequationin the document (should there be any) would be left unaltered.(You could use the blacklist pattern
^theas in this particular example to identify redefinitions of formatting of LaTeX counters, but then all macros that begin with “the” would not be substituted, and for instance\newcommand{\therefore}{...}would not be replaced.)envbody_begin, envbody_end: When expanding environments, the entire replacement LaTeX code is wrapped by these two strings. By default, envbody_begin=’{’ and envbody_end=’}’, such that all expansions of environments are enclosed within a LaTeX group. You may specify any other prefixes and postfixes here (e.g.
\begingroupand\endgroupor empty strings to avoid creating a LaTeX group).Placing the environment contents in a group imitates what LaTeX itself does. If you don’t put the contents in a group, you might change the resulting document output (for instance, if you have an
\itshapeinside the environment, the group would ensure the italic text doesn’t continue outside of the environment).
- class latexpp.fixes.macro_subst.Subst(*, macros={}, environments={})¶
Define macros and environments that will be replaced by corresponding custom LaTeX code.
Update
See
latexpp.fixes.newcommand.Expandfor a fix that automatically detects\newcommandinstructions and performs replacements in the document body. The difference between that fix and this fix is that here, you need to specify all defined macros with their substitution text manually. There, everything is automatically detected.Arguments:
macros: a dictionary of macro substitution rules
{<macro-name>: <macro-info>, ...}. The key <macro-name> is the macro name without the leading backslash.The value <macro-info> is a dictionary
{'argspec': <argspec>, 'repl': <repl>}, where <argspec> specifies the argument structure of the macro and <repl> is the replacement string. If <macro-info> is a string, then the string is interpreted as the <repl> and ‘<argspec>’ is set to an empty string (which indicates that the macro does not expect any arguments).The <argspec> is a string of characters ‘*’, ‘[’, or ‘{’ which indicate the nature of the macro arguments:
A ‘*’ indicates a corresponding optional * in the LaTeX source (starred macro variant);
a ‘[’ indicates an optional argument delimited in square brackets; and
a ‘{’ indicates a mandatory argument.
The argument values can be referred to in the replacement string <repl> using the syntax ‘%(n)s’ where n is the argument number, i.e., the index in the argspec string.
For instance:
macros={ 'includegraphics': {'argspec': '[{', 'repl': '<%(2)s>'} }
would replace all
\includegraphicscalls by the string<filename>, while ignoring any optional argument if it is present. (\includegraphicshas an optional argument and a mandatory argument.)You can also use
%(macroname)sin the <repl> string, which will expand to the name of the macro without the leading backslash.environments: a dictionary of environment substitution rules
{<environment-name>: <environment-info>, ...}. The key <environment-name> is the name of the environment, i.e., what goes as argument to\begin{...}and\end{...}.The <environment-info> is a dictionary
{'argspec': <argspec>, 'repl': <repl>}where <argspec> specifies the structure of the arguments accepted immediately after\begin{<environment>}(as for{ccrl}in\begin{tabular}{ccrl}). The <argspec> works exactly like for macros.The replacement string <repl> works exactly like for macros, with the additional substitution key
%(body)sand that can be used to include the body of the environment in the replacement string. (The body is itself also preprocessed by latexpp.)You can also use
%(environmentname)sin the repl string, which will expand to the name of the environment.Note
For a starred version of an environment (like
\begin{align*}), the star is part of the environment name and NOT part of the <argspec>. I.e., you should specifyenvironments={'align*': ...}and NOTenvironments={'align': {'argspec':'*',...}}. This is because the <argspec> represents the arguments parsed after the\begin{...}command. That is, if we used ‘*’ in the <argspec>, the syntax\begin{align}*would be recognized instead of\begin{align*}.
Tweaking document contents¶
- class latexpp.fixes.environment_contents.InsertPrePost(environmentnames=None, pre_contents=None, post_contents=None)¶
Find instances of a specific environment and insert contents in its body, before or after the existing contents.
This fix can be useful for instance to add a
\qedcommand in some LaTeX styles at the end of proofs (\begin{proof} ... \end{proof}→\begin{proof} ... \qed\end{proof}).Arguments:
environmentnames is a list of names of environments upon which to act (e.g.,
['proof'];pre_contents is arbitrary LaTeX code to insert at the beginning of the environment body, for each environment encountered whose name is in environmentnames;
post_contents is arbitrary LaTeX code to insert at the end of the environment body, for each environment encountered whose name is in environmentnames.
- class latexpp.fixes.ifsimple.ApplyIf(ifnames=None)¶
Very simplistic parser for ifXXX…else…fi structures in a document.
Note
This “parser” is much more rudimentary than TeX’s offering. Your document might compile fine but this fix might choke on it.
The main difference is that here, all if-else-fi commands must occur within the same logical block (e.g., group or environment). The code
\iftrue {\bfseries \else {\itshape \fi contents}will not work for instance, even if it works in TeX, because it interleaves braced groups with the if structure.This fix is aware of a few built-in
\ifXXXcommands (\iftrue,\iffalse, etc.) and attempts to detect custom ifs declared with\newif. Provide any additional\ifXXXcommand names using the ifnames argument.ifnames — a dictionary of TeX if-command names and corresponding True/False values.
E.g.
{'ifsomething': True, 'ifsomethingelse': False}
References and citations¶
- class latexpp.fixes.ref.ExpandRefs(*, only_ref_types=None, make_hyperlinks=True, expand_only_prefixes=False, remove_usepackage_cleveref=None, latex_command='pdflatex', debug_latex_output=False)¶
Expands references in the document. Includes support for cleveref references.
Reference expansion means replacing a LaTeX reference command by its actual substitution with the corrsponding number, replacing e.g.
\eqref{eq:abc}by(13)or\cref{fig:xyz}byFigure~3, possibly creating a link if appropriate.The expansion text of the reference commands is computed by running LaTeX on a specially-generated temporary document in a temporary directory, with special LaTeX commands that reveal the text that would be typeset for those references by extracting the relevant information from your document’s AUX file. (You need to have run latex/pdflatex on your document first, to create the AUX file in the first place.)
Arguments:
only_ref_types: limit expansion to selected reference kind. If non-None, it should be a set or list containing one or more of (‘ref’, ‘ams-eqref’, ‘autoref’, ‘cleveref’)
make_hyperlinks: If the hyperref package is loaded, then hyperlinks commands to the appropriate targets are generated in the document.
expand_only_prefixes=[‘LIST’, ‘OF’, ‘PREFIXES’]: Only do the expansion for reference labels that start with one of the given prefixes. This is useful, for instance, if you load labels from external documents with a prefix and you only want to expand those.
One way to load external labels is with the zref-xr package:
\usepackage{zref-xr} \zxrsetup{toltxlabel} \zexternaldocument*[PREFIX]{OtherDocument}
remove_usepackage_cleveref: remove any occurrence of
\usepackage[options..]{cleveref}. Default: True if ‘cleveref’ is one of the reference types acted upon (see only_ref_types) and if the expansion is not for specific prefixes, otherwise False.latex_command: latex executable to run. By default, ‘pdflatex’. (Can also specify absolute path.)
debug_latex_output: If set to True, will print out LaTeX output in verbose mode (logger debug level). Default: False
- class latexpp.fixes.labels.RenameLabels(*, label_rename_fmt='%(prefix)s%(hash)s', ref_types=None, use_hash_length=12, use_hash_encoding='b64', hack_phfthm_proofs=False)¶
Detect labels pinned with label{} and replace all future references in known referencing commands.
Arguments:
label_rename_fmt: a python %-format string to generate the new label. Use fields of the type
"%(prefix)s%(hash)s"or%(n)d. Keys can include:labelname(earlier label name);n(a simple incremental counter for each label);hash(a hash of the earlier label);prefix(detects the prefix like “thm:” or “eq:”, including colon; expands to empty if no prefix);num_labels(total number of detected labels).[I will probably add more fields in the future.]
ref_types: which reference command types to recognize when replacing labels. Here we use the same syntax as the
latexpp.fixes.ref.ExpandRefsfilter.Additionally, you can specify the ‘bib’ “reference type” to act on bibliographic entries; labels will be searched for (and replaced) in
\bibitem{}commands and replacements will occur in citation-related commands like\cite{},\citet{}, etc. By default, bibliographic labels are not touched.use_hash_length: The key “%(hash)s” in label_rename_fmt computes the MD5 hash of the previous label and truncates its encoded representation (see use_hash_encoding) at use_hash_length chars.
use_hash_encoding: one of ‘hex’ (hexadecimal) or ‘b64’ (base64 with ‘-’ and ‘.’ chars instead of ‘+’ and ‘/’)
- class latexpp.fixes.bib.CopyAndInputBbl(bblname=None, outbblname=None, eval_input=False)¶
Copy the (latex-generated) BBL file from the current directory into the output directory, and replace a
\bibliographycall by\input{<BBLFILE>}.Note
Multiple bibliographies are not supported.
Arguments:
bblname: the name of the BBL file to include. If None or not provided, the bbl name is derived from the main latex file name.
outbblname: the bbl file is copied to the output directory and renamed to outbblname. By default this derived from the main output latex file name.
eval_input: Directly paste the BBL file contents into the TeX file rather than issuing a
\input{XXX.bbl}directive.
- class latexpp.fixes.bib.ApplyAliases(bibaliascmd='bibalias', bibalias_defs_search_files=[], aliases={})¶
Scans the files bibalias_def_search_files for bibalias commands
\bibalias{alias}{target}(or whatever macro is given to bibaliascmd), and applies the aliases to all known citation commands (from the natbib doc). Any bibalias commands are encountered in the input they are stored as aliases. Further manual aliases can be specified using the aliases={…} argument.
Figures¶
- class latexpp.fixes.figures.CopyAndRenameFigs(fig_rename='fig-{fig_counter:02}{fig_ext}', start_fig_counter=1, graphicspath='.', exts=None)¶
Copy graphics files that are included by
\includegraphicscommands to the output directory. By default, they are renamed in figure order, ‘fig-01.jpg’, ‘fig-02.pdf’, etc.Arguments:
fig_rename: Template to use when renaming the graphics file in the output directory. The string is parsed by python’s
str.format()mechanism, and the following keys are provided:‘{fig_counter}’, ‘{fig_counter:02}’ – the figure number. Use ‘:0n’ to format the number with n digits and leading zeros.
‘{fig_ext}’ – the file name extension, including the dot.
‘{orig_fig_name}’ – the original figure file name
‘{orig_fig_basename}’ – the original figure file name, w/o extension
‘{orig_fig_ext}’ – the original figure file extension
start_fig_counter: Figure numbering starts at this number (by default, 1).
graphicspath: Filesystem path where to look for graphics files
exts: Extensions to search for when looking up graphics files.
Preamble, packages, local files, and other dependencies¶
- class latexpp.fixes.usepackage.CopyLocalPkgs(blacklist=None, recursive=True)¶
Copy package style files that are present in the current directory and that are included with
\usepackage{...}.Package style files are copied to the output directory as-is (no fixes are applied within the style file). If the recursive flag is set, the style file is also parsed (but not preprocessed) to detect further package inclusions that we should copy to the output directory.
Warning
[FIXME]: This does not work if you have
\usepackagedirectives with several packages. This should be easy to fix…Arguments:
blacklist: a list of package names (without the ‘.sty’ extension) for which we should not copy the style file, even if found in the current working directory.
recursive: If True, then this fix also recursively inspects the copied package sources to detect further packages to inlcude.
- class latexpp.fixes.usepackage.RemovePkgs(pkglist)¶
Remove some instances of
\usepackage[..]{...}for some selected pacage names.Arguments:
pkglist: List of package names for which we should remove any
\usepackagedirectives.
Warning
[FIXME]: This does not work if you have
\usepackagedirectives with several packages. This should be easy to fix…
- class latexpp.fixes.preamble.AddPreamble(preamble=None, fromfile=None)¶
Include arbitrary LaTeX code before
\begin{document}.Arguments:
preamble: the additional code to include before
\begin{document}.
- class latexpp.fixes.deps.CopyFiles(files=[])¶
Copies the given files to the output directory. Use this for dependencies that aren’t obvious, like a custom LaTeX class.
For packages, you can use
latexpp.fixes.usepackage.CopyLocalPkgs. For figures, consider usinglatexpp.fixes.figures.CopyAndRenameFigs.Arguments:
files: a list of files to include in the output directory. The files are not renamed and subdirectories are preserved.
Each element in files is either:
a single file name, in which case the destination file name and relative path is preserved, or
a dictionary of the form
{'from': source_file, 'to': dest_file}, in which case the file source_file is copied to dest_file, where dest_file is relative to the output directory.
Example:
fixes: [...] - name: 'latexpp.fixes.deps.CopyFiles' config: files: # copy my-suppl-mat-xyz.pdf -> output/SupplMaterial.pdf - from: my-suppl-mat-xyz.pdf to: SupplMaterial.pdf # copy ReplyReferees.pdf -> output/ReplyReferees.pdf - ReplyReferees.pdf
Act on parts of your document¶
- class latexpp.fixes.regional_fix.Apply(region=None, fixes=None)¶
Apply a regional fix, i.e., apply a set of rules to a delimited section of your document.
This fix looks for one or more delimited sections in your document (see below) whose name matches the given argument region. On those delimited sections, a specified list of custom fixes are executed. The fixes to run are specified in the fixes argument, with a format that is exactly the same as the global fixes: dictionary key in the lppconfig.yml file.
The section of your document that you would like to apply the specified fixes to is marked using a
%%!lpppragma instruction of the form:%%!lpp regional-fix My-Region-Name-1 { ... ... %%!lpp }Arguments:
region: is the name of the region that the given extra fixes should be applied to. In your LaTeX code, you should have a
%%!lpp regional-fixpragma instruction that delimits the sections of code on which these fixes should be applied. In the example above, region=”My-Region-Name-1”.fixes: a data structure of fixes configuration like the main fixes section of the latexpp configuration. You can specify here any fixes that you could specify for the document at the top level.
Create archive with all files¶
- class latexpp.fixes.archive.CreateArchive(use_root_dir=True, use_date=True, archive_type='zip')¶
Create an archive with all the generated files.
This rule must be the last rule!
Arguments:
use_root_dir: If True, then the archive will contain a single directory with all the files. The directory name is the same as the output directory. If False, then all the files are placed in the archive at the root level.
use_date: If True, the current date/time is appended to the archive file name.
archive_type: One of ‘zip’, ‘tar’, ‘tar.gz’, ‘tar.bz2’, ‘tar.xz’.
Package-specific fixes¶
These fix classes expand the definitions that are provided by a given package in order to remove the dependency of a document on that package.
- class latexpp.fixes.pkg.cleveref.ApplyPoorMan¶
Applies the replacements provided by cleveref‘s “poor man” mode.
Warning
OBSOLETE: It is strongly recommended to use the
latexpp.fixes.ref.ExpandRefsfix instead, which supports cleveref references.Make sure you use cleveref with the
[poorman]package option, like this:\usepackage[poorman]{cleveref}
After this fix, the file no longer depends on the {cleveref} package. Note, there are some limitations of cleveref’s “poor man” mode that we can’t get around here.
- class latexpp.fixes.pkg.phfqit.ExpandQitObjects(qitobjs={}, qitobjdef=['stdset'], HSym='H', DSym='D', DCSym='\\hat{D}', wrap_delimited_in_latex_group=False, qitobjs_emulate_phfqit_appearance=False)¶
Expand the definitions for the “QIT Objects” that are defined via the {phfqit} package.
If applied along with
latexpp.fixes.pkg.phfqit.ExpandMacros, the dependency on package {phfqit} should be removed.Arguments:
qitobjs: a dictionary of custom “QIT Objects” to expand. The dictionary has the structure
{macroname: qitobjspec, ...}, where:macroname is the name of the macro representing this QIT object (no leading backslash);
qitobjspec is a dictionary with the following structure:
{ 'type': <type>, 'sym': <sym> <...> }
The <type> is a string that must be one of the following QIT object types: ‘Hbase’, ‘Hfnbase’, ‘DD’, ‘Dbase’, ‘DCohbase’, ‘IdentProc’, ‘ee’. This determines on one hand how the arguments to the macro are parsed and on the other hand the template latex code that will serve as a replacement for the QIT object invocation.
The <sym> is any string that will be used to override the default symbol for this qit object type. The ‘sym’ key can be left out to use the default symbol for the qit object.
Depending on <type>, you can specify further keys that specify how the qit object is rendered (specified alongside type: <type> above, where <…> stands):
<type>=’Hbase’: You may further specify
'sub': <sub>which specifies the subscript to add to the entropy object. This can be any LaTeX code.<type>=’Hfnbase’: You may further specify
'sub': <sub>and'sup': <sup>which specifies the subscript and superscript to add to the entropy object. Both can be any LaTeX code.<type>=’Dbase’: You may further specify
'sub': <sub>which specifies the subscript to add to the relative entropy object. This can be any LaTeX code. You can also specify ‘default_epsilon’ to give a default value of the epsilon argument (any LaTeX code).<type>=’Dalpha’: You can also specify ‘default_alpha’ and ‘default_epsilon’ to give a default value for these arguments (any LaTeX code).
<type>=’DD’: There are no further keys you can specify.
<type>=’DCohbase’: There are no further keys you can specify.
<type>=’IdentProc’: There are no further keys you can specify.
<type>=’ee’: There are no further keys you can specify.
qitobjdef: a list of built-in QIT object sets to use, designated by builtin set name. Currently only the set named “stdset” is available, i.e., you may use
qitobjdef=[](don’t use built-in QIT objects) orqitobjdef=['stdset'](use built-in QIT objects).HSym: the default symbol to use for entropy-like QIT objects. Defaults to ‘H’
DSym: the default symbol to use for relative-entropy-like QIT objects. Defaults to ‘D’
DCSym: the default symbol to use for coherent-relative-entropy-like QIT objects. Defaults to ‘\hat{D}’
wrap_delimited_in_latex_group: whether to wrap contents of delimited expressions into LaTeX groups to avoid line breaks inside an entropy argument (false by default).
qitobjs_emulate_phfqit_appearance: will include additional hacks to try to emulate phfqit.sty’s appearance as best as possible; will include e.g. empty subscript/superscript groups, etc., as necessary.
- class latexpp.fixes.pkg.phfqit.ExpandMacros(*, subst=None, ops=None, delims=None, math_operator_fmt='\\operatorname{%(opname)s}', subst_use_hspace=True, subst_space=None, llanglefrommnsymbolfonts=False)¶
Expand various macros defined by the {phfqit} package.
If applied along with
latexpp.fixes.pkg.phfqit.ExpandQitObjects, the dependency on package {phfqit} should be removed.Arguments:
subst: a dictionary of substitutions to perform. The dictionary keys are macro names without leading backslash, and values are dictionaries of the form
{'qitargspec': <qitargspec>, 'repl': <repl>}. This has a similar syntax to thelatexpp.fixes.macro_subst.Substfix class, but argument parsing allows an extended syntax. Instead of specifying an ‘argspec’: <argspec>, you specify ‘qitargspec’: <qitargspec> which provides argument parsing extensions to the usual argspec.Each character in <qitargspec> is one of:
‘*’, ‘[’, ‘{’ represent the same kind of arguments as for ‘argspec’ in
latexpp.fixes.macro_subst.Subst;‘(’ represents a mandatory argument in parentheses;
‘`’ represents an optional argument introduced by
`<token or group>;‘_’ represents an optional argument introduced by
_<token or group>;or ‘^’ which represents an optional argument introduced by
^<token or group>.
As for
latexpp.fixes.macro_subst.Subst, arguments are available in the replacement string <repl> via the syntax%(n)swhere n is the argument number.A default set of substitutions are provided according to the macros defined in the {phfqit} package; arguments here override the defaults. You can disable individual default substitutions by providingthe value None (null in the YAML file) for the given macro name in the subst dictionary.
ops: a dictionary of “operator names” to substitute for. This is a dictionary
{<opname>: <opstring>, ...}where <opname> is the macro name of the operator without leading backslash (e.g.,trfor “trace”), and <opstring> is the replacement LaTeX string that will be formatted as an operator name. See math_operator_fmt= for how operators are formatted.A default set of operator names are provided according to the macros defined in the {phfqit} package; arguments here override the defaults. You can disable individual default operator names by providing the value None (null in the YAML file) for the given operator name in the ops dictionary.
math_operator_fmt: The template string to use to format an operator. By default, we use \operatorname{…} to format the operator. The template should contain the string %(opname)s which will be replaced by the actual operator name. The default value is
\operatorname{%(opname)s}; if you prefer to use\mboxfor operators, you could set this to\mbox{%(opname)s}.delims: A dictionary specifying macros that format delimited expressions (such as \abs, \ket, \norm, etc.). These macros take an optional star (which indicates that the delimiters should be latex-dynamically sized with
\leftand\right), or an optional sizing macro in square braces (such as\norm[\big]{...}). After the optional star and optional argument, the macro must take a fixed number of mandatory arguments (e.g., one for\normbut two for\ketbraand three for\matrixel).The delims argument is a dictionary
{<delim-macro-name>: <delim-spec>, ...}where <delim-macro-name> is the name of the macro without leading backslash (e.g., ‘ket’ or ‘abs’). The <delim-spec> is either:<delim-spec>=(<left-delim>, <right-delim>), i.e., a two-item tuple or list specifying the left and right delimiter. The macro must take a single mandatory argument, which will be typeset between the two delimiters. One must be able to size the delimiters using sizing commands such as
\bigor\left/\right.<delim-spec>=(<left-delim>, <contents-repl>, <right-delim>), i.e., a three-item tuple or list. The <left-delim> and <right-delim> are as above. The <contents-repl> specifies how to format the contents between the two delimiters, and should contain replacement strings of the form
%(n)sthat expand into the n-th mandatory argument of the macro. The number of mandatory arguments that the macro accepts is inferred by inspecting the replacement string and looking for the highest n in these replacement placeholders. Furthermore, you can use the replacement placeholder%(delimsize)s, which expands to the relevant sizing command (e.g.,\big,\middleto match\left/\right, or nothing if no sizing options are given) and which can be placed immediately before a delimiter.<delim-spec>={‘open’: <left-delim>, ‘close’: <right-delim>, ‘repl’: <contents-repl>, ‘default-size’: r’big’, ‘prefix’: <prefix-content>, ‘suffix’: <suffix-content>} enables you to additional specify a default sizing argument if no size argument was specified, as well as additional fixed pieces of string to render before the opening delimiter (prefix) and after the closing delimiter (suffix).
subst_use_hspace: In all the above substitutions (including delimiters), there are some custom sizing corrections in the form of
\hspace*{XXex}that adjust the spacing between the different symbols in the expansion of those macros. By default, they are kept in the replacement latex code so that the document looks the same when compiled. If instead, you would like simple substitutions without these fine-tuning spacing commands, set subst_use_hspace=False.llanglefrommnsymbolfonts: If set to True, then include preamble definitions that will make available the ‘llangle’ and ‘rrangle’ commands by picking the corresponding symbols from the MnSymbols font. (see https://tex.stackexchange.com/a/79701/32188)
- class latexpp.fixes.pkg.phfthm.Expand(deftheorems=['theorem', 'lemma', 'proposition', 'corollary'], proofenvs={'proof': 'proof'}, ref_type='\\cref{%s}', proof_of_name='Proof of %s', use_shared_counter=False, define_thmheading=False)¶
Expand theorem definitions to remove {phfthm} package dependency.
- class latexpp.fixes.pkg.phfparen.Expand(wrap_in_latex_group=False)¶
Expand expressions provided by the {phfparen} package, such as
`*(...)or`{...}, into equivalent LaTeX code that does not require the {phfparen} package.This fix removes the dependency on the {phfparen} package. (That is, unless you defined custom delimiters etc. via {phfparen} internals or if you did other weird stuff like that…)
Arguments:
wrap_in_latex_group: If set to true (false by default), then the delimited math contents is wrapped in a
{...}group. This prevents line breaks within the delimited expression, as is the case when you use the phfparen latex package.