pythonimmediate.pytotex module

Receive things that should be passed to \(\TeX\) from \(\TeX\)-to-Py half (pythonimmediate.textopy), then pass to \(\TeX\).

User code are not executed here.

For Python-inside-:math:`TeX` only (does not apply to ChildProcessEngine): Anything that is put in pythonimmediatedebugextraargs environment variable will be appended to the command-line arguments. For example you could invoke \(\TeX\) with pythonimmediatedebugextraargs='--debug-log-communication=/tmp/a.diff --debug=5' pdflatex test.tex to enable debugging facilities.

Side note --debug-log-communication also accept a $pid placeholder. That is, if you pass --debug-log-communication=/tmp/a-$pid.diff, then the $pid will be replaced with the process ID. This is useful if you want to run multiple \(\TeX\) processes at the same time and want to log them separately.

Supported command-line arguments:

usage: pytotex [-h] [-m {unnamed-pipe,multiprocessing-network}] [-d DEBUG]
               [--sanity-check-extra-line] [--no-sanity-check-extra-line]
               [--debug-log-communication DEBUG_LOG_COMMUNICATION]
               [--debug-force-buffered] [--naive-flush]

Named Arguments

-m, --mode

Possible choices: unnamed-pipe, multiprocessing-network

The mode of communication.

Refer to pythonimmediate.communicate for the detail on what each mode mean.

-d, --debug

Debug level. In [0..9].

Default: 0

--sanity-check-extra-line

Sanity check that there’s no extra line printed from [TeX] process. Should never be necessary unless the package is buggy. Might not work on Windows/MikTeX.

Default: False

--no-sanity-check-extra-line

Default: True

--debug-log-communication

Debug mode, log all communications. Pass the output path. For example you may want to specify --debug-log-communication=/tmp/a.diff to log all communication to a.diff file (because the lines are prefixed with < and >, diff syntax highlighting works nicely with it). Placeholder $pid is supported.

--debug-force-buffered

Debug mode, simulate [TeX] writes being 4096-byte buffered. Don’t use.

“This may raise the error message Fatal Python error: could not acquire lock for <_io.BufferedReader name='<stdin>'> at interpreter shutdown, possibly due to daemon threads because of how it’s implemented (a daemon thread read from stdin and forward to a pipe), but this feature is only used for debugging anyway so it does not matter.

Default: False

--naive-flush

Naively flush stdout by writing 4096 bytes to it when needed. Required in some [TeX] distribution that does not flush output.

Default: False