I want to render a two columns pdf document using markdown fenced divs. The minimal example is this :
:::::::::::::: {.columns data-latex=""} ::: {.column width="40%" data-latex="[t]{0.4\textwidth}"} contents... ::: ::: {.column width="60%" data-latex="[t]{0.6\textwidth}"} contents... ::: :::::::::::::: The rendering is OK in html, but apparently somebody decided that multicolumn rendering in latex is for beamer only, so it doesn't work with plain latex and then with pdf. I can't switch to pandoc's html pdf engine since I need latex templating for my final document.
The minipage latex environment seems very convenient to achieve what I want. After quite a lot of investigations, I came with this lua filter :
local pandocList = require 'pandoc.List' Div = function (div) local options = div.attributes['data-latex'] if options == nil then return nil end -- if the output format is not latex, the object is left unchanged if FORMAT ~= 'latex' and FORMAT ~= 'beamer' then div.attributes['data-latex'] = nil return div end local env = div.classes[1] -- if the div has no class, the object is left unchanged if not env then return nil end local returnedList -- build the returned list of blocks if env == 'column' then local beginEnv = pandocList:new{pandoc.RawBlock('tex', '\\begin' .. '{' .. 'minipage' .. '}' .. options)} local endEnv = pandocList:new{pandoc.RawBlock('tex', '\\end{' .. 'minipage' .. '}')} returnedList = beginEnv .. div.content .. endEnv end return returnedList end Unfortunately, the generated latex document (pandoc --lua-filter ./latex-div.lua -o test.latex test.md) is the following which doesn't render as intended because of the blank line between the end of the first minipage and the begining of the second one :
\begin{document} \begin{minipage}[t]{0.4\textwidth} contents\ldots{} \end{minipage} \begin{minipage}[t]{0.6\textwidth} contents\ldots{} \end{minipage} \end{document} I am almost there. How can I get rid of this unwanted blank line without reprocessing the latex file ?