Pandoc Column Slides

I would like to have the code and image side by side in the Beamer slide.

In LaTeX, I would do this using columns. I would like to use markdown in the column structure.

\begin{columns} \column{.5\textwidth} ~~~~~~~~Python >>> some python code ~~~~~~~ \column{.5\textwidth} ![](A_generated_image.pdf) \end{columns} 

Unfortunately, Pandoc does not handle markdowns in the \ begin {columns} and \ end {columns} statements. Is there any way around this?

  • Is there a way to use markdowns inside the built-in LaTeX?
  • Is there a clean markdown solution?
+18
markdown latex pandoc beamer
Feb 28 '13 at 17:43
source share
4 answers

The problem is that pandoc ignores markdowns if it finds \begin{} . An alternative is to edit the ray chart template and add the following:

 \newcommand{\columnsbegin}{\begin{columns}} \newcommand{\columnsend}{\end{columns}} 

And write it like this:

 \columnsbegin \column{.5\textwidth} ~~~~~~~~Python >>> some python code ~~~~~~~ \column{.5\textwidth} ![](A_generated_image.pdf) \columnsend 
+16
Sep 26 '14 at 23:35
source share

Hopefully still valuable. I made a Pandoc filter in Python to easily place columns so you can write your presentations this way:

 # Hello World [columns] [column=0.5] ~~~python if __name__ == "__main__": print "Hello World" ~~~ [column=0.5] This is how a "Hello World" looks like in Python [/columns] 

so that the filter converts each markup to \ begin {columns} and \ column {.5 \ textwidth}, so in the above document will appear

 \begin{frame}[fragile]{Hello} \begin{columns} \column{0.5\textwidth} \begin{Shaded} \begin{Highlighting}[] \NormalTok{some python code} \end{Highlighting} \end{Shaded} \column{0.5\textwidth} Hello World \end{columns} \end{frame} 

Code filter here

 import pandocfilters as pf def latex(s): return pf.RawBlock('latex', s) def mk_columns(k, v, f, m): if k == "Para": value = pf.stringify(v) if value.startswith('[') and value.endswith(']'): content = value[1:-1] if content == "columns": return latex(r'\begin{columns}') elif content == "/columns": return latex(r'\end{columns}') elif content.startswith("column="): return latex(r'\column{%s\textwidth}' % content[7:]) if __name__ == "__main__": pf.toJSONFilter(mk_columns) 

If you never use the pandoc filter, just save the filter in the same place in the document as columnfilter.py (or another name you want) and run

 pandoc -t beamer --filter columnfilter.py yourDocument.mkd 

And enjoy it!

+14
Jun 04 '14 at 14:23
source share

You can use the FletcherPenney MultiMarkdown, which can handle markdowns up to LaTeX / Beamer. Compared to Pandoc, MultiMarkdown has few features. However, especially when working with LaTeX, it has the advantage that you can embed LaTeX code directly in Markdown comments in HTML comments.

Your code will look like this:

 <!-- \begin{columns} --> <!-- \column{.5\textwidth} --> >>> some python code <!-- \column{.5\textwidth} --> ![](A_generated_image.pdf) <!-- \end{columns} --> 

For me, this solution works great. With a good editor (e.g. Scrivener, Sublime Text) you can write latex code without comments and find / replace them after editing. In addition, Multimarkdown's Metadata support is much more flexible, making it easier to create presentations.

In the meantime, I hope the Pandoc team provides a solution to this problem. I think there are some users who would like to embed small parts of LaTex code in all markdown documents without converting / escaping them.

+2
Apr 24 '13 at 15:00
source share

You can use MultiMarkDown comments ("<! - your LaTeX code inside โ†’") with Pandoc when you conclude a Pandoc command in which you convert markdowns to LaTeX with two sed commands.

In the first sed experiment, you change the MultiMarkDown comments to "\ verb + AAAAAAALaTeX-StuffZZZZZZ +". Then you turn into LaTeX with Pandoc, as usual, everything inside "\ verb + AAAAAAALaTeX-StuffZZZZZZZ +" stays alone. Then you run sed in the TeX file and delete "\ verb + AAAAAAA" and "ZZZZZZ +", deploying your LaTeX code.

The first sed command line before the Pandoc conversion might look like this:

  sed -E -e "s/<\\!--(.+)--\\>/\\\\verb\+AAAAAAA\1ZZZZZZZ\+/g " \ source.md > source.i.md 

Then use Pandoc on source.i.md, as usual, to create source.tex. The second sed works as follows:

  sed -E -e "s/\\\\verb\+AAAAAAA(.+)ZZZZZZZ\+/\1/g" -i "" source.tex 

I automated everything in the Makefile so that I can make more changes, for example. to define tables in one step. At first glance, this approach works just fine (tested it for definitions of columns with a ray class).

With these little sed scripts, you can use all the nice things from Pandoc. You only need to mmd-comment on those TeX and LaTeX commands that either escape or cover large parts of your Markdown.

+2
May 03 '13 at 19:32
source share



All Articles