双列布局中的LaTeX文件可以使用figure*
环境而不是标准figure
来制作全宽图形。我正在通过RMarkdown/pandoc生成我的LaTeX,所以不确定我是否可以/如何以这种方式控制图形环境。有什么简单的方法可以做到这一点吗?也许只需覆盖figure
环境定义?
例如,安装rticles
R包,然后使用-> PNAS模板(两列模板)创建新的rmarkdown模板。
这提供了一个默认示例,该示例从markdown中呈现一个1列宽的图形:

编织.Rmd模板,您将看到这将创建一个使用\begin{figure}
的.tex
文件。您可以对模板示例进行哪些更改,以强制pandoc将图形放在\begin{figure*}
环境中(除了在tex
文件上手动查找-替换之外)?
发布于 2020-12-10 21:55:16
这是一个pandoc Lua filter,我正在使用它来实现类似的目的。它基本上复制了pandoc的图形创建机制,但可以自由更改。
local function inline_latex(s)
return pandoc.RawInline('latex', s)
end
local function to_label(s)
return string.format(
'\\label{%s}\n',
s:gsub('([^%a%d%_%-%+%=%:%;%.])',
function (x)
io.stderr:write 'WARNING: Unicode char in label might not work!'
return x
end
)
)
end
--- Create custom code for figures
function Para (p)
-- A paragraph is a figure if it contains an image and nothing else.
local img = p.content[1]
if img and img.t == 'Image' and #p.content == 1 then
local linebreak = inline_latex '\n'
local label = img.identifier ~= "" and
inline_latex(to_label(img.identifier)) or
inline_latex ""
return pandoc.Para{
inline_latex('\\begin{figure*}'),
img, linebreak,
inline_latex('\\caption'), pandoc.Span(img.caption), linebreak,
label,
inline_latex('\\end{figure*}')
}
end
end
这种方法的局限性是图形标签中的Unicode字符不再可能--这可以通过调整to_label
函数来解决。
查看这个伟大的Bookdown manual section,了解更多关于Lua过滤器的信息,以及如何将它们与R Markdown一起使用。
https://stackoverflow.com/questions/65226013
复制相似问题