tecosaur / org-latex-preview-todos

A tracker for the Org LaTeX Preview effort on https://git.tecosaur.net/tec/org-mode
5 stars 0 forks source link

Add support for latexmk #38

Open karthink opened 3 months ago

karthink commented 3 months ago

Some LaTeX packages require running LaTeX multiple times to generate correct output (and hence previews). An example of this is the nicematrix CTAN package. Using latexmk as the :latex-compiler in org-latex-preview-process-alist runs without errors, but doesn't actually produce correct previews.

Example (from https://list.orgmode.org/m1v801dlof.fsf@nobis-it.eu/T/#u):

#+latex_header: \usepackage{nicematrix}
#+latex_header: \newcolumntype{C}{c}

#+begin_src emacs-lisp
(plist-put (alist-get 'dvisvgm org-latex-preview-process-alist)
           :latex-compiler
           '("latexmk  -f -latex -output-directory=%o %f"))
#+end_src

\begin{equation*}
  A^{0}=
  \begin{pNiceArray}{C|CCC}[margin]
    -m^{00}& 0 & 0 & 0\\
    \hline
    0 & \Block{3-3}{-m^{ab}}& &\\
    0 & & & \\
    0 & & & \\
  \end{pNiceArray}
  \qquad
  A^{k}=
  \begin{pNiceArray}{C|CCC}[margin]
    -2m^{0k}& m^{1k} & m^{2k} & m^{3k}\\
    \hline
    m^{1k}& \Block{3-3}{0_{3\times3 }}& &\\
    m^{2k}& & & \\
    m^{3k}& & &
  \end{pNiceArray}
\end{equation*}

Produces: image

Corresponding MWE LaTeX file:

\documentclass{article}
\usepackage{nicematrix}
\newcolumntype{C}{c}
\begin{document}
\begin{equation*}
  A^{0}=
  \begin{pNiceArray}{C|CCC}[margin]
    -m^{00}& 0 & 0 & 0\\
    \hline
    0 & \Block{3-3}{-m^{ab}}& &\\
    0 & & & \\
    0 & & & \\
  \end{pNiceArray}
  \qquad
  A^{k}=
  \begin{pNiceArray}{C|CCC}[margin]
    -2m^{0k}& m^{1k} & m^{2k} & m^{3k}\\
    \hline
    m^{1k}& \Block{3-3}{0_{3\times3 }}& &\\
    m^{2k}& & & \\
    m^{3k}& & &
  \end{pNiceArray}
\end{equation*}
\end{document}
yantar92 commented 3 months ago

pNiceArray is incompatible with latex (but not with pdflatex), which is the main problem. We need pdflatex or latexmk -pdf