Solution for Avoiding line break between RawBlocks
is Given Below:
I have a Pandoc filter written in Lua that converts certain Div
s into RawBlock
s. My problem is that Pandoc seems to insert a newline between these RawBlock
s in the LaTeX output, which messes with the layout since newlines between subfigure
s are significant.
As far as I can see, my filter doesn’t make any newlines:
if FORMAT ~= 'latex' then
return {}
end
function Div(elem)
if elem.classes:includes("subtikz") then
return { pandoc.RawBlock('latex', '\begin{subfigure}'),
elem,
pandoc.RawBlock('latex', '\end{subfigure}') }
end
if elem.classes:includes("figure") then
return { pandoc.RawBlock('latex', '\begin{figure}'),
elem,
pandoc.RawBlock('latex', '\end{figure}') }
end
return nil
end
And yet, with a simple Markdown input file, we can see the problem:
<div class="figure">
hspace{-2cm}
<div class="subtikz"></div>
<div class="subtikz"></div>
vspace{8ex}
<div class="subtikz"></div>
</div>
(this is of course heavily simplified — in my real use case I can have content inside the <div class="subtikz">
, which is why it’s a div
).
This results in:
$ pandoc --lua-filter latex-output-space.lua latex-output-space.md -t latex
begin{figure}
hspace{-2cm}
begin{subfigure}
end{subfigure}
begin{subfigure}
end{subfigure}
vspace{8ex}
begin{subfigure}
end{subfigure}
end{figure}
Note the extra lines after the end{subfigure}
lines. How do I get rid of them? My intended output would be:
begin{figure}
hspace{-2cm}
begin{subfigure}
end{subfigure}
begin{subfigure}
end{subfigure}
vspace{8ex}
begin{subfigure}
end{subfigure}
end{figure}