dialoa / imagify

Pandoc/Quarto filter to convert selected LaTeX elements to images in other output formats
https://dialoa.github.io/imagify/
MIT License
15 stars 1 forks source link

Parsing macros to imagify #16

Open amael-ls opened 1 month ago

amael-ls commented 1 month ago

First of all, many thanks for this extension!

I am trying to use a macro and a tikzstyle in a TikZ picture but they both seem to fail:

  1. \newcommand{\env}{\mathcal{E}}
  2. \tikzstyle{arrow} = [->, > = Latex, very thick]

I am going to show the problem with tikzstyle only as I suspect the problems to be similar.


Here is the code that works (provided imagify is installed of course): test_work.qmd:

---
title: "Test"
lang: en-GB
pdf-engine: lualatex
filters:
  - imagify
imagify:
  header-includes: |
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    \usetikzlibrary{arrows.meta}
  pdf-engine: lualatex
format:
  html:
    toc: true
  pdf:
    include-in-header:
      - text: |
          \usepackage{tikz}
          \usetikzlibrary{positioning}
          \usetikzlibrary{arrows.meta}
---

![A test](./testFig_work.tex){#fig-testFig}

testFig_work.tex:

\begin{tikzpicture}
    %% Define nodes
    \node (N0) at (0, 0) {N0};
    \node[right = of N0] (N1) {N1};

    \draw[->, > = Latex, very thick] (N0) -- (N1);
\end{tikzpicture}

Here is the code that does not work: test_fail.qmd:

---
title: "Test"
lang: en-GB
pdf-engine: lualatex
filters:
  - imagify
imagify:
  header-includes: |
    \usepackage{tikz}
    \usetikzlibrary{positioning}
    \usetikzlibrary{arrows.meta}
    \tikzstyle{arrow} = [->, > = Latex, very thick]
  pdf-engine: lualatex
format:
  html:
    toc: true
  pdf:
    include-in-header:
      - text: |
          \usepackage{tikz}
          \usetikzlibrary{positioning}
          \usetikzlibrary{arrows.meta}
          \tikzstyle{arrow} = [->, > = Latex, very thick]
---

![A test](./testFig_fail.tex){#fig-testFig}

testFig_fail.tex:

\begin{tikzpicture}
    %% Define nodes
    \node (N0) at (0, 0) {N0};
    \node[right = of N0] (N1) {N1};

    \draw[arrow] (N0) -- (N1);
\end{tikzpicture}

I gathered in a zip the four files.

I am doing anything wrong or is there a bug in transmitting the macros and tikzstyle? test.zip

amael-ls commented 1 month ago

Note that I also posted on tex stack exchange: https://tex.stackexchange.com/questions/719168/parsing-macros-and-tikzstyle-in-quarto-imagify-lua-filter

amael-ls commented 1 month ago

Ok, the error comes from the fact that tikzstyle is outdated and that tikzset should be used instead (see the complete answer on tex.stackexchange).

\tikzset{arrow/.style = {->, > = Latex, very thick}}