You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it seems that currently it is only possible to pass multiple arguments/options to commands, not environments. However, this would be a useful addition., i.e. it should be possible to do something like this
::: {.env arguments="1,2"}
body
:::
which should result in
\begin{env}{1}{2}
body
\end{env}
The same should also be possible for options.
I developed something that at least works for my purposes by editing _extensions/latex-environment/latex-environment.lua and basically copying what is already implemented for commands. However, as I'm not really familiar with Lua nor particualrly profficient with LaTeX, I did not want to open a PR directly. Here's what I did:
Redefine buildCommandArgs (now simply called buildArgs since it is also for environments):
-- helper function to parse multiple options/arguments --localfunctionbuildArgs(opts, format)
localfunctionwrap(o)
returnstring.format(format, o)
endlocalt=pandoc.List()
locallast_pos=1opts=opts.."," -- Add a trailing comma to handle the last argumentforstrinstring.gmatch(opts, "([^,]*),") doifstr=="" thent:insert("")
elset:insert(str)
endendreturntable.concat(t:map(wrap), "")
end
This is basically the same as the buildCommandArgs, however, I tried to add the possibility of leaving arguments empty, i.e by using ::: {.env arguments=",2,3"}. This should probably be considered a separate issue.
Additionaly, I updated writeEnvironment:
-- Use the environments from metadata to emit a custom environment for LaTeXlocalfunctionwriteEnvironments(divEl)
ifquarto.doc.is_format("latex") thenfork, vinpairs(classEnvironments) doifdivEl.attr.classes:includes(k) then-- Process this into a LaTeX environmentlocalbeginEnv='\\begin' ..'{' ..v..'}'localendEnv='\n\\end{' ..v..'}'-- Check if custom options or arguments are present-- and add them to the environment accordinglylocalopts=divEl.attr.attributes['options']
ifoptsthenbeginEnv=beginEnv..buildArgs(opts, "[%s]")
endlocalargs=divEl.attr.attributes['arguments']
ifargsthenbeginEnv=beginEnv..buildArgs(args, "{%s}")
end-- If the first and last div blocks are paragraphs, -- bring the environment begin/end closer to the contentif#divEl.content>0anddivEl.content[1].t=="Para" anddivEl.content[#divEl.content].t=="Para" thentable.insert(divEl.content[1].content, 1, pandoc.RawInline('tex', beginEnv.."\n"))
table.insert(divEl.content[#divEl.content].content, pandoc.RawInline('tex', "\n" ..endEnv))
elsetable.insert(divEl.content, 1, pandoc.RawBlock('tex', beginEnv))
table.insert(divEl.content, pandoc.RawBlock('tex', endEnv))
endreturndivElendendendend
Obviously, also change all other mentions of buildCommandArgs.
I hope this can be implemented sometime. As I said, I'm not too comfortable with Lua and LaTeX, so this should probably be checked more thoroughly then I was capable of.
In the meantime, there is also the (ugly) workaround of using
::: {.env arguments="1}{2}{3"}
body
:::
The text was updated successfully, but these errors were encountered:
Hey,
it seems that currently it is only possible to pass multiple arguments/options to commands, not environments. However, this would be a useful addition., i.e. it should be possible to do something like this
which should result in
The same should also be possible for options.
I developed something that at least works for my purposes by editing
_extensions/latex-environment/latex-environment.lua
and basically copying what is already implemented for commands. However, as I'm not really familiar with Lua nor particualrly profficient with LaTeX, I did not want to open a PR directly. Here's what I did:Redefine
buildCommandArgs
(now simply calledbuildArgs
since it is also for environments):This is basically the same as the
buildCommandArgs
, however, I tried to add the possibility of leaving arguments empty, i.e by using::: {.env arguments=",2,3"
}. This should probably be considered a separate issue.Additionaly, I updated
writeEnvironment
:Obviously, also change all other mentions of
buildCommandArgs
.I hope this can be implemented sometime. As I said, I'm not too comfortable with Lua and LaTeX, so this should probably be checked more thoroughly then I was capable of.
In the meantime, there is also the (ugly) workaround of using
The text was updated successfully, but these errors were encountered: