Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

latex - Slides with Columns in Pandoc

I would like to have code and an image side-by-side in a Beamer slide.

In LaTeX I would do this with columns. I would like to use markdown within the column structure.

egin{columns}
column{.5extwidth}

~~~~~~~~Python
>>> some python code
~~~~~~~

column{.5extwidth}

![](A_generated_image.pdf)

end{columns}

Unfortunately Pandoc doesn't process the markdown within the egin{columns} and end{columns} statements. Is there a way around this?

  • Is there a way to use markdown within inlined LaTeX?
  • Is there a pure markdown solution?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Current versions of pandoc (i.e., pandoc 2.0 and later) supports fenced divs. Specially named divs are transformed into columns when targeting a slides format:

# This slide has columns

::: columns

:::: column
left
::::

:::: column
right
::::

:::

Pandoc translates this into the following LaTeX beamer code:

egin{frame}{This slide has columns}
protecthypertarget{this-slide-has-columns}{}

egin{columns}[T]
egin{column}{0.48extwidth}
left
end{column}

egin{column}{0.48extwidth}
right
end{column}
end{columns}

end{frame}

This is simple and has the additional advantage of giving similar results when targeting other presentational formats like reveal.js.

More than two columns work out of the box for Beamer output. Powerpoint, however, only supports two columns. For reveal.js, the widths of three or more columns must be given explicitly:

::: columns

:::: {.column width=30%}
left
::::

:::: {.column width=30%}
middle
::::

:::: {.column width=30%}
right
::::

:::

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...