From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/33502 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "'lukeflo' via pandoc-discuss" Newsgroups: gmane.text.pandoc Subject: Re: Lua filter to change macro for figure caption md -> latex Date: Mon, 11 Dec 2023 02:36:29 -0800 (PST) Message-ID: <32dfe8eb-98ac-40ee-92d7-162528add367n@googlegroups.com> References: <51ca8210-3d60-4d5d-9af2-04c85995deb6n@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_37548_87698096.1702290989043" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3392"; mail-complaints-to="usenet@ciao.gmane.io" To: pandoc-discuss Original-X-From: pandoc-discuss+bncBD7NXUVXXUBBBLWM3OVQMGQEA3S4L6Y-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Mon Dec 11 11:36:34 2023 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane-mx.org Original-Received: from mail-oo1-f57.google.com ([209.85.161.57]) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1rCdeL-0000kR-TD for gtp-pandoc-discuss@m.gmane-mx.org; Mon, 11 Dec 2023 11:36:34 +0100 Original-Received: by mail-oo1-f57.google.com with SMTP id 006d021491bc7-58d5bb052dfsf5186524eaf.3 for ; Mon, 11 Dec 2023 02:36:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1702290993; x=1702895793; darn=m.gmane-mx.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:x-original-sender :mime-version:subject:references:in-reply-to:message-id:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=Kv6hQoBwzeSbM5wy8njtHVOPJOyIJ31KLdLcv6KXgM0=; b=D4FHXC+8y1N/uu3evQc9wIUWVn606O0o4ycqU63AZOVW6kPs+g1t56Xrp3nJrrxLtB SXGGeVH+th5WxhqM+hbjEgsO3Ng4qR8H8aek/D6xp7uCUNfhlkww/122iW1R/YbHI8Ir cwjuWTapCJAl51lWipTvX3e4D2n6XXNUcNpHtT2CL+jlP8IBydEftZN1BGsVc5YX93wB 8s3Z2mDGLwpL4pO1VjjlMx984Q58tQtH5qrE7MTCjNKkHedpLciM6Q4g5XB+cKgtq0e0 6bY7V0zCQFVmxKPooGNdO5bTEWXaIxhgSy1SFwkoIoqwppZ/SYdPcqMLlfZLH0lk3SqE 5hfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702290993; x=1702895793; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-sender:mime-version:subject:references:in-reply-to :message-id:to:from:date:x-beenthere:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Kv6hQoBwzeSbM5wy8njtHVOPJOyIJ31KLdLcv6KXgM0=; b=duPmmt2pweYTpAqv5npDh+XAufJQbVT2zzgPppYCxDLjhHtrDks+m+iKaIKcXi9Dxe gApdhLa5eTuFUyovN6ruoKVX8JaNDYarLBZSzzad3fbD7RC4YqviCKziniwHhQRM9Od1 /AXlLpeaoWb/tPg4go9rDRV83aNhsQoYXWBt+arQ7pNhfevDCB+3PAyIzXPdSNgC7VJV AmAl9qNljsFfPRCvcKHEAHjQBiX/I62zlpZjOt1rlCYgFHhfyYL32WxVHtD1Y2ROeysN 56tbZS1xCUYE8bxDJClQBezZHPwV/uR6cJZv8riZO1C1hr/El+VkmM6il X-Gm-Message-State: AOJu0YwT93ZoVhLs2DKUV7OC3/MF7otCi5oronQGHsoAgftK7NGkhNnh uGl68R6+ytR7o280Ur8ov7o= X-Google-Smtp-Source: AGHT+IECL3Kh3OFZFPIZRD96g/DFjoLIPVq6/iNEY93sAgQnZ5DW5qDvKWQyza6ITgAmxMzy5mMWmw== X-Received: by 2002:a05:6820:820:b0:58d:7171:c27 with SMTP id bg32-20020a056820082000b0058d71710c27mr4893797oob.8.1702290992726; Mon, 11 Dec 2023 02:36:32 -0800 (PST) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 2002:a05:6820:602:b0:58f:7a18:580 with SMTP id e2-20020a056820060200b0058f7a180580ls4426784oow.0.-pod-prod-07-us; Mon, 11 Dec 2023 02:36:29 -0800 (PST) X-Received: by 2002:a05:6830:2b2a:b0:6d9:d132:c041 with SMTP id l42-20020a0568302b2a00b006d9d132c041mr4058139otv.6.1702290989618; Mon, 11 Dec 2023 02:36:29 -0800 (PST) In-Reply-To: X-Original-Sender: k.flo.west-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org X-Original-From: lukeflo Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.io gmane.text.pandoc:33502 Archived-At: ------=_Part_37548_87698096.1702290989043 Content-Type: multipart/alternative; boundary="----=_Part_37549_1159589810.1702290989043" ------=_Part_37549_1159589810.1702290989043 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable PS: I know I'm using two very different approaches calling the Figure=20 function with arguments. Thats due to the fact that I'm not sure which way= =20 is the right one... lukeflo schrieb am Montag, 11. Dezember 2023 um 11:33:21 UTC+1: > So far, I took the markdwon writer example from the pandoc docs=20 > = =20 > to try out the general function of writers. It works and I think that I= =20 > understand the general usage. > > But especially figures (in latex writer and presuambley in general) are= =20 > relativley complex. Here are two things I tried out so far but always got= =20 > an error: > > ``` lua > function Writer (doc, opts) > local filter =3D { > function Figure (caption, image, attr) > local figcap =3D '\sidecaption{' .. caption .. '}' > return '\\begin{figure}\n' .. image .. '\n' .. figcap .. '\n'=20 > '\\end{figure}\n' > end > } > return pandoc.write(doc:walk(filter), 'latex', opts) > end > ``` > If I run this writer with my custom template from the CLI using *pandoc= =20 > --template=3D../custom.template -t test-writer.lua ast-test.txt -o=20 > ast-test.tex* I get=20 > *Error running Lua:test-writer.lua:27: '(' expected near 'Figure'*. > > Furthermore, I tried running the following code just to understand how=20 > those writer work. Here I just wanted to replace {figure} with the starre= d=20 > version {figure*} (not sidecaption): > > ``` lua > function Writer (doc, opts) > local filter =3D { > Figure =3D function (fig) > local tester =3D '\\begin{figure*}\n' ..=20 > fig.content[1].caption[1].attributes[1] .. '\\end{figure*}\n' > return pandoc.RawBlock('latex', tester) > end > } > return pandoc.write(doc:walk(filter), 'latex', opts) > end > ``` > But also got an error: > > > > > > > > > *Error running Lua:test-writer.lua:28: attempt to index a nil value (fiel= d=20 > 'caption')stack traceback: [C]: in ? [C]: in method 'walk'=20 > test-writer.lua:32: in function 'Writer'stack traceback:=20 > test-writer.lua:32: in function 'Writer'* > > I'm aware that I might be missing something very basic and maybe even ver= y=20 > simple. But I'm kind of getting lost a little bit inside all functions,= =20 > modules etc. as well as the general framework of such writers. > > Thus, any help explaining my errors and maybe suggesting some better code= =20 > is very appreciated! > > The test file in both cases is very simple: > > ``` markdown > --- > title: A title > --- > > # Headline > > Some text > > ![caption to an image](counter_plot_new_periods.png) > ``` > > Thanks in advance! > lukeflo schrieb am Freitag, 8. Dezember 2023 um 08:35:48 UTC+1: > >> Hello Julien, >> >> thanks for the reply. Unfortunatley, as mentioned in the stackoverflow= =20 >> post, your suggested LaTeX code won't work. >> >> The \caption macro is very complex in the backend and cannot be copied= =20 >> on the fly via \let, \NewCommandCopy or something similar. Even after=20 >> doing so with e.g. \NewCommandCopy{\oldcaption}{\caption} and then=20 >> setting \RenewDocumentCommand{\caption}{o m}{\sidecaption[#1]{#2}}=20 >> nothing changes and the definition of \caption, checked with \meaning or= =20 >> something similar, stays the same as before (even \DeclareDocumentComman= d=20 >> doesn't work). >> >> In the end, it might be possible to somehow change the \caption macro=20 >> itself. But the effort might not be worth the result (and its more of a= =20 >> question for TeX.SE). >> >> Using a custom writer for building Latex figures and replace the \captio= n=20 >> string inside would be a great solution. I read through the writer manua= l,=20 >> but didn't really understand how the AST works and which values have to = be=20 >> used in such a writer. Furthermore, I'm using a a custom Latex template = for=20 >> exporting (based on the default.template.latex) which has to be integrat= ed=20 >> with such a writer. >> >> Therefore, I really woud appreciate a Lua framework to understand which= =20 >> functions have to be edited etc. to accomplish the substitution. >> >> Best >> >> Julien Dutant schrieb am Dienstag, 5. Dezember 2023 um 17:09:19 UTC+1: >> >>> Lua filters only change Pandoc's AST representation of your document,= =20 >>> i.e. before it is then converted to LaTeX. A Raw block filter will not = act=20 >>> on Pandoc's LaTeX output, but only on Raw LaTeX blocks that are in the= =20 >>> markdown itself. >>> >>> A Pandoc solution would be to write a custom Lua *writer*=20 >>> . The writer would use=20 >>> pandoc.write to generate Pandoc's own LaTeX output (body only) and modi= fy=20 >>> it with regular expressions or Lua patterns. To replace just a command = name=20 >>> this is fairly easy, though longer than the third solution below. >>> >>> A LaTeX solution is to redefine \caption as \sidecaption: >>> \renewcommand{\caption}{\sidecaption}=20 >>> >>> You can keep this enclosed in groups ({...}) to ensure that the=20 >>> redefinition only applies locally. >>> >>> A hybrid Pandoc/LaTeX solution is a Lua filter that insert LaTeX code t= o=20 >>> redefine \caption around figures: >>> >>> ``` lua >>> if FORMAT:match 'latex' then >>> function Figure (elem) return {=20 >>> pandoc.RawBlock('latex', >>> '{\\renewcommand{\\caption}{\\subcaption}'),=20 >>> elem,=20 >>> pandoc.RawBlock('latex','}')=20 >>> }=20 >>> end=20 >>> end >>> >>> ``` >>> >>> This replaces any 'Figure' block element by a list (succession) of thre= e=20 >>> raw LaTeX blocks. The output should look like: >>> {\renewcommand{\caption}{\subcaption}=20 >>> ... Pandoc's LaTeX for the figure ...=20 >>> }=20 >>> >>> Reposted from=20 >>> https://stackoverflow.com/questions/77504584/pandoc-md-latex-write-lua-= filter-to-change-latex-macro-used-for-caption/77607636#77607636 >>> >>> On Monday, November 20, 2023 at 7:06:57=E2=80=AFAM UTC+11 lukeflo wrote= : >>> >>>> Hi everybody, >>>> >>>> I have written a custom latex `.cls' file to establish a typesetting >>>> workflow for the scientific journals of my research institute. The tex= ts >>>> should be written in Markdown and then be processed with `pandoc' to >>>> LaTeX. >>>> >>>> I already have an elaborated pandoc template to produce the LaTeX >>>> preambel etc. So far its working great. >>>> >>>> But for the figures I need the caption from the Markdown file to be se= t >>>> with `\sidecaption' instead of `\caption' in LaTeX, as well as with an >>>> optional argument (short-caption) for the image attribution in the lis= t >>>> of figures. >>>> >>>> To get the latter working I use the following template from a GitHub >>>> discussion in the [pandoc repo]: >>>> >>>> =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 >>>> =E2=94=82 PANDOC_VERSION:must_be_at_least '3.1' >>>> =E2=94=82 >>>> =E2=94=82 if FORMAT:match 'latex' then >>>> =E2=94=82 function Figure(f) >>>> =E2=94=82 local short =3D f.content[1].content[1].attributes['shor= t-caption'] >>>> =E2=94=82 if short and not f.caption.short then >>>> =E2=94=82 f.caption.short =3D pandoc.Inlines(short) >>>> =E2=94=82 end >>>> =E2=94=82 return f >>>> =E2=94=82 end >>>> =E2=94=82 end >>>> =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 >>>> >>>> That works without any flaws. >>>> >>>> But now I need to figure out how to change the LaTeX macro used for th= e >>>> caption. The older [approach of pre pandoc version 3.0 posted] by tarl= eb >>>> is really intuitive and I could have easily adapted it to my needs. Bu= t >>>> since pandoc 3.0 there is the new [/complex figures/] approach and, so >>>> far, I couldn't figure out how to change the LaTeX macro used for the >>>> captions with this new behaviour. >>>> >>>> I tried something like that (Adapted from [here]: >>>> >>>> =E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80 >>>> =E2=94=82 if FORMAT:match 'latex' then >>>> =E2=94=82 function RawBlock (raw) >>>> =E2=94=82 local caption =3D raw.text:match('\\caption') >>>> =E2=94=82 if caption then >>>> =E2=94=82 raw:gsub('\\caption', '\\sidecaption') >>>> =E2=94=82 end >>>> =E2=94=82 return raw >>>> =E2=94=82 end >>>> =E2=94=82 end >>>> =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80 >>>> >>>> But nothing happened. >>>> >>>> The main challenge for me are my more-or-less non-existing lua skills.= I >>>> just never had to use it for my daily tasks. I thought about using `aw= k' >>>> or `sed' to edit the `.tex' file itself using a regex-substitution, bu= t >>>> that should remain an absolute stopgap, since it makes the whole >>>> workflow less portable. >>>> >>>> Thus, I'm hoping for a hint/a solution in form of a pandoc-lua script >>>> which 1. helps me to achieve the goal, and 2. improve my understanding >>>> of lua and the /complex figures/ approach for similar future tasks. >>>> >>>> I appreciate any tipp! >>>> >>>> Best, >>>> Lukeflo >>>> >>>> This question is also posted on StackOverFlow:=20 >>>> https://stackoverflow.com/q/77504584/19647155 >>>> >>>> [pandoc repo] >>>> >>>> >>>> [approach of pre pandoc version 3.0 posted] >>>> >>>> >>>> [/complex figures/] >>>> >>>> [here] >>>> >>> --=20 You received this message because you are subscribed to the Google Groups "= pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an e= mail to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/= pandoc-discuss/32dfe8eb-98ac-40ee-92d7-162528add367n%40googlegroups.com. ------=_Part_37549_1159589810.1702290989043 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable PS: I know I'm using two very different approaches calling the Figure funct= ion with arguments. Thats due to the fact that I'm not sure which way is th= e right one...

lukeflo schrieb am Montag, 11. Dezember 2023 um 11:33:21 U= TC+1:
So= far, I took the markdwon wri= ter example from the pandoc docs to try out the general function of wri= ters. It works and I think that I understand the general usage.
<= br>
But especially figures (in latex writer and presuambley in ge= neral) are relativley complex. Here are two things I tried out so far but a= lways got an error:

``` lua
function= Writer (doc, opts)
=C2=A0 =C2=A0local filter =3D {
=C2=A0 =C2=A0 =C2= =A0 function Figure (caption, image, attr)
=C2=A0local figcap =3D '\sidecaption{' .. caption .. = 9;}'
=C2=A0return '\\beg= in{figure}\n' .. image .. '\n' .. figcap .. '\n' '\= \end{figure}\n'
=C2=A0 =C2=A0 =C2=A0 end
=C2=A0 =C2=A0}
=C2=A0= =C2=A0return pandoc.write(doc:walk(filter), 'latex', opts)
end<= /div>
```
If I run this writer with my custom template fr= om the CLI using=C2=A0pandoc --template=3D../custom.template -t test-wri= ter.lua ast-test.txt -o ast-test.tex I get Error running Lua:
tes= t-writer.lua:27: '(' expected near 'Figure'
.
=
Furthermore, I tried running the following code just to unde= rstand how those writer work. Here I just wanted to replace {figure} with t= he starred version {figure*} (not sidecaption):

``= ` lua
function Writer (doc, opts)
=C2=A0 local filter =3D {=C2=A0 =C2=A0 =C2=A0Figure =3D function (fig)
local tester =3D '\\begin{figure*}\n' .. fig.content= [1].caption[1].attributes[1] .. '\\end{figure*}\n'
return pandoc.RawBlock('latex', tester= )
=C2=A0 =C2=A0 end
=C2=A0 }
=C2=A0 return pandoc.write(doc:walk(f= ilter), 'latex', opts)
end
```
But also got = an error:

Error running Lua:
test-writer.lua= :28: attempt to index a nil value (field 'caption')
stack traceb= ack:
[C]: in ?
[C]: in method 'walk'
test-writer.lua:32: in function 'Writer'stack traceback:
test-writer.lu= a:32: in function 'Writer'

I'm awa= re that I might be missing something very basic and maybe even very simple.= But I'm kind of getting lost a little bit inside all functions, module= s etc. as well as the general framework of such writers.

Thus, any help explaining my errors and maybe suggesting some better= code is very appreciated!

The test file in both c= ases is very simple:

``` markdown
--= -
title: A title
---

# Headline

Some text

![capt= ion to an image](counter_plot_new_periods.png)
```
=
Thanks in advance!
lukeflo schrieb am Freitag, 8. Dezember 2= 023 um 08:35:48 UTC+1:
Hello Julien,

thanks for the reply. Unfortun= atley, as mentioned in the stackoverflow post, your suggested LaTeX code wo= n't work.

The \caption macro is v= ery complex in the backend and cannot be copied on the fly via \let, \NewCommandCopy or something similar. Even after doing = so with e.g. \NewCommandCopy{\oldcaption}{\caption} and then s= etting \RenewDocumentCommand{\caption}{o m}{\sidecaption[#1]{#2}} nothing changes and the definition of \caption, checked wi= th \meaning or something similar, stays the same as before (ev= en \DeclareDocumentCommand doesn't work).

In the end, it might be possible to somehow change the \caption macro itself. But the effort might not be worth the result (and its mo= re of a question for TeX.SE).

Using a custom writer for building Latex figures and replace the \captio= n string inside would be a great solution. I read through the writer manual= , but didn't really understand how the AST works and which values have = to be used in such a writer. Furthermore, I'm using a a custom Latex te= mplate for exporting (based on the default.template.latex) which has to be = integrated with such a writer.

Therefore, I really woud appreciate a = Lua framework to understand which functions have to be edited etc. to accom= plish the substitution.

Best


Julien Dutant schrieb am Diensta= g, 5. Dezember 2023 um 17:09:19 UTC+1:

Lua filters only change Pandoc's AST representation of your document= , i.e. before it is then converted to LaTeX. A Raw block filter will not=20 act on Pandoc's LaTeX output, but only on Raw LaTeX blocks that are in= =20 the markdown itself.

A Pandoc solution would be to write a custom Lua writer. The writer would use pandoc.write to generate Pandoc's own LaTeX outpu= t (body only) and modify it with regular expressions or Lua patterns. To=20 replace just a command name this is fairly easy, though longer than the=20 third solution below.

A LaTeX solution is to redefine \caption as \sidecaption:

\renewcommand{\caption}{\sidecaption}

You can keep this enclosed in groups ({...}) to ensure that the redefini= tion only applies locally.

A hybrid Pandoc/LaTeX solution is a Lua filter that insert LaTeX code to= redefine \caption around figures:

``` lua

if FORMAT:match 'latex'= then
= =C2=A0=C2=A0=C2=A0 function Figure (e= lem) return {=C2=A0
=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pandoc.RawBlock('latex= 9;,'{\\renewcommand{\\caption}{\\subcaption}'),= =C2=A0
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 elem,=C2=A0
=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 pandoc.RawBlock('latex= ','}')=C2=A0
= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 }
<= span>=C2=A0=C2=A0 end
end

```

This replaces any 'Figure' block element by a list (succession) = of three raw LaTeX blocks. The output should look like:

{\renewcommand{\caption}{\subcaption}=C2=A0
=
... Pandoc's LaTeX for the figure ...=C2=A0
}


On Monday, November= 20, 2023 at 7:06:57=E2=80=AFAM UTC+11 lukeflo wrote:
Hi everybody,

I have written a custo= m latex `.cls' file to establish a typesetting
workflow for the scie= ntific journals of my research institute. The texts
should be written in= Markdown and then be processed with `pandoc' to
LaTeX.

I alr= eady have an elaborated pandoc template to produce the LaTeX
preambel et= c. So far its working great.

But for the figures I need the caption = from the Markdown file to be set
with `\sidecaption' instead of `\ca= ption' in LaTeX, as well as with an
optional argument (short-caption= ) for the image attribution in the list
of figures.

To get the la= tter working I use the following template from a GitHub
discussion in th= e [pandoc repo]:

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94=80
= =E2=94=82 PANDOC_VERSION:must_be_at_least '3.1'
=E2=94=82
=E2= =94=82 if FORMAT:match 'latex' then
=E2=94=82 =C2=A0 function Fi= gure(f)
=E2=94=82 =C2=A0 =C2=A0 local short =3D f.content[1].content[1].= attributes['short-caption']
=E2=94=82 =C2=A0 =C2=A0 if short and= not f.caption.short then
=E2=94=82 =C2=A0 =C2=A0 =C2=A0 f.caption.short= =3D pandoc.Inlines(short)
=E2=94=82 =C2=A0 =C2=A0 end
=E2=94=82 =C2= =A0 =C2=A0 return f
=E2=94=82 =C2=A0 end
=E2=94=82 end
=E2=94=94= =E2=94=80=E2=94=80=E2=94=80=E2=94=80

That works without any flaws.
But now I need to figure out how to change the LaTeX macro used for t= he
caption. The older [approach of pre pandoc version 3.0 posted] by tar= leb
is really intuitive and I could have easily adapted it to my needs. = But
since pandoc 3.0 there is the new [/complex figures/] approach and, = so
far, I couldn't figure out how to change the LaTeX macro used for= the
captions with this new behaviour.

I tried something like tha= t (Adapted from [here]:

=E2=94=8C=E2=94=80=E2=94=80=E2=94=80=E2=94= =80
=E2=94=82 if FORMAT:match 'latex' then
=E2=94=82 =C2=A0 f= unction RawBlock (raw)
=E2=94=82 =C2=A0 =C2=A0 local caption =3D raw.tex= t:match('\\caption')
=E2=94=82 =C2=A0 =C2=A0 if caption then
= =E2=94=82 =C2=A0 =C2=A0 =C2=A0 =C2=A0raw:gsub('\\caption', '\\s= idecaption')
=E2=94=82 =C2=A0 =C2=A0 end
=E2=94=82 =C2=A0 =C2=A0 = return raw
=E2=94=82 =C2=A0 end
=E2=94=82 end
=E2=94=94=E2=94=80= =E2=94=80=E2=94=80=E2=94=80

But nothing happened.

The main ch= allenge for me are my more-or-less non-existing lua skills. I
just never= had to use it for my daily tasks. I thought about using `awk'
or `s= ed' to edit the `.tex' file itself using a regex-substitution, but<= br>that should remain an absolute stopgap, since it makes the whole
work= flow less portable.

Thus, I'm hoping for a hint/a solution in fo= rm of a pandoc-lua script
which 1. helps me to achieve the goal, and 2. = improve my understanding
of lua and the /complex figures/ approach for s= imilar future tasks.

I appreciate any tipp!

Best,
Lukeflo<= br>
This question is also posted on StackOverFlow: https://stackoverflow.com/q/7= 7504584/19647155

[pandoc repo]
<https://github.com/jgm/pandoc/issues/7915#issuecomment-1427113349>

[approach of pre pandoc version 3.0 posted]
<
https://github.com/jgm/pandoc/issues/7915#issuecomm= ent-1039370851>

[/complex figures/] <https://github.com/jgm/pa= ndoc/releases?page=3D2>

[here] <https://stackoverflow.com/a/712965= 95/19647155>
<= /div>

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d= /msgid/pandoc-discuss/32dfe8eb-98ac-40ee-92d7-162528add367n%40googlegroups.= com.
------=_Part_37549_1159589810.1702290989043-- ------=_Part_37548_87698096.1702290989043--