
El siguiente mwe produce un archivo MAKE no válido cuando se usa con la opción latexmk
' -output-directory
. (El ejemplo es del pgfplots
manual)
latexmk mwe.tex -output-directory=build
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize[mode=list and make]
\begin{document}
\input{tikz/figure.tikz}
\end{document}
y un archivo bajotikz/figure.tikz
\begin{figure}
\begin{tikzpicture}
\begin{axis}
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\caption{Our first external graphics example}
\end{figure}
con el archivo MAKE enbuild/mwe.makefile
ALL_FIGURE_NAMES=$(shell cat mwe.figlist)
ALL_FIGURES=$(ALL_FIGURE_NAMES:%=%.pdf)
allimages: $(ALL_FIGURES)
@echo All images exist now. Use make -B to re-generate them.
FORCEREMAKE:
include $(ALL_FIGURE_NAMES:%=%.dep)
%.dep:
mkdir -p "$(dir $@)"
touch "$@" # will be filled later.
mwe-figure0.pdf:
pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "mwe-figure0" "\def\tikzexternalrealjob{mwe}\input{mwe}"
mwe-figure0.pdf: mwe-figure0.md5
como el mwe.tex
archivo no está en el build
directorio, ejecutar el make
comando desde el build
directorio no funcionará; Además, ejecutarlo desde el directorio "raíz" de proyectos no funcionará, ya que no hay ninguno mwe.figlist
allí.
Respuesta1
Esta solución es un truco sucio, por lo que no la aceptaré, esperando que alguien dé una mejor respuesta.
Una solución alternativa actual que tengo es modificar los comandos utilizados para crear el archivo MAKE; esta idea es deaquíy modificar los comandos, incluido subir un directoriocd .. &&
y configurando el directorio de salida--output-directory=./build
como sigue:
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize[mode=list and make]
\tikzset{%
external/system call={cd .. && pdflatex \tikzexternalcheckshellescape --halt-on-error --interaction=batchmode --output-directory=./build --jobname "\image" "\texsource"},
/pgf/images/include external/.code={%
\includegraphics{build/#1}%
},
}
\begin{document}
\input{tikz/figure.tikz}
\end{document}
generando el nuevo makefile
ALL_FIGURE_NAMES=$(shell cat mwe.figlist)
ALL_FIGURES=$(ALL_FIGURE_NAMES:%=%.pdf)
allimages: $(ALL_FIGURES)
@echo All images exist now. Use make -B to re-generate them.
FORCEREMAKE:
include $(ALL_FIGURE_NAMES:%=%.dep)
%.dep:
mkdir -p "$(dir $@)"
touch "$@" # will be filled later.
mwe-figure0.pdf:
cd .. && pdflatex -shell-escape --halt-on-error --interaction=batchmode --output-directory=./build --jobname "mwe-figure0" "\def\tikzexternalrealjob{mwe}\input{mwe}"
mwe-figure0.pdf: mwe-figure0.md5
que ahora se puede construir desde el build
directorio con make -f mwe.makefile
.