jbn / itikz

Cell and line magic for PGF/TikZ-to-SVG rendering in Jupyter notebooks
MIT License
62 stars 9 forks source link

some code requires multiple executions of the engine #20

Open ea42gh opened 4 years ago

ea42gh commented 4 years ago

Description

latex engine needs executing more than once.

What I Did

%%itikz --temp-dir --implicit-standalone --tex-packages=nicematrix,tikz
\NiceMatrixOptions{code-for-last-row = \color{red}, code-for-first-row = \color{red}}
$\begin{pNiceArray}{cccc|c}[left-margin = 4pt, first-col, last-row,
    code-before =
    {
    \tikz \draw[red!55] (row-1-|col-1) -- (row-2-|col-1) -- (row-2-|col-3) -- (row-3-|col-3) -- (row-3-|col-6);
    }
]
                               & \color{red}{1}   & 2 & 1                  & 1 & \;  5 \\
                               & 0                    & 0 & \color{red}{2} & 1 & \; -1 \\
                               & 0                    & 0 & 0                  & 0 &     0 \\
\color{blue}{\begin{matrix} \text{basic variables} \\ \text{free variables} \end{matrix}} & \begin{matrix}\ x_1 \\ \\ \end{matrix} & \begin{matrix}\\ \ x_2=\alpha \\ \end{matrix} & \begin{matrix}\ x_3\\ \\ \end{matrix} & \begin{matrix} \\ \ x_4=\beta \\ \end{matrix} & \\
\end{pNiceArray}$

the tikz path is not shown

ea42gh commented 4 years ago

I hacked the code to add a parameter nexec:

for _ in range(nexec-1):
    subprocess.run([tex_program, tex_filename], cwd=working_dir)
check_output([tex_program, tex_filename], cwd=working_dir)
check_output(["pdf2svg", pdf_path, svg_path], cwd=working_dir)

the example above requires nexec=4

fpantigny commented 3 years ago

I suggest you to use the option --tex-program of itikz with the value latexmk (which will do the required TeX compilations for you).

%%itikz --temp-dir --implicit-standalone --tex-packages=nicematrix --tex-program=latexmk