PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
254 stars 202 forks source link

Recompile latex images as needed #2140

Closed siefkenj closed 1 month ago

siefkenj commented 1 month ago

Some tex images require multiple compilations before they reach their "finished" form. Automatically recompiling as necessary is handled by tools like latexmk. It seems that PreTeXt, however, does not do this.

Is this feature missing, or is there a flag that needs to be set? (I have some images which need to be compiled 3 times to reach their final form).

rbeezer commented 1 month ago

We only compile the main document twice, while tcolorbox can require three passes. So this needs some thought. I guess a LaTeX-specific instruction on 'latex-image" would not be such a strange thing?

rbeezer commented 1 month ago

Jason - can you provide an example here, hopefully one that does not require too many preamble-type additions? Thanks.

On March 12, 2024 5:50:21 PM PDT, Rob Beezer @.***> wrote:

We only compile the main document twice, while tcolorbox can require three passes. So this needs some thought. I guess a LaTeX-specific instruction on 'latex-image" would not be such a strange thing?

siefkenj commented 1 month ago
\documentclass[10pt]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{geometry}
\geometry{letterpaper,total={340pt,9.0in}}
%% Custom Page Layout Adjustments (use publisher page-geometry)
\usepackage{amsmath,amssymb}
\usepackage{nicematrix}
\usepackage{tikz}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\begin{document}
\pagestyle{empty}
\resizebox{\width}{\height}{
\begin{tikzpicture}
\node{
    $\begin{bNiceArray}{ccc|cc}[
    code-before={\cellcolor{LimeGreen!72}{1-1,2-2,3-3}\cellcolor{NavyBlue!72}{1-2,2-3,3-4}\cellcolor{CornflowerBlue!72}{1-3,2-4,3-5}}
    ]
    3 & 4 & 0 & 1 & 4 \\
    -2 & 3 & 1 & -2 & 3 \\
    0 & 2 & 1 & 0 & 2
    \end{bNiceArray}$
};
\end{tikzpicture}
}
\end{document}
siefkenj commented 1 month ago

I looked at the latexmk source code. It looks in the log file for a line containing Rerun to get (This is a substring of, LaTeX Warning: Label(s) may have changed. Rerun to get cross-references right.). If that line is present, it will recompile.

I think pretext should follow the same convention when compiling images. Then no guesswork should be needed.

rbeezer commented 1 month ago

Closed via #2142