# A markdown_in_tex_blocks extension #2453

Open
opened this issue Oct 15, 2015 · 9 comments

Contributor

### yihui commented Oct 15, 2015

 This is a feature request to add a Markdown extension markdown_in_tex_blocks like markdown_in_html_blocks according to the discussion in the mailing list: https://groups.google.com/forum/#!msg/pandoc-discuss/ggcrRN-ja-s/lNeILZdlBwAJ Thanks!

### andreatta commented Nov 17, 2015

 +1 That is a feature I really would like to see. I am trying to put two separate tables next to each other on the same line. \begin(minipage}[b]{8mm} #table 1 \end{minipage} \begin(minipage}[b]{8mm} #table 2 \end{minipage}
referenced this issue Dec 6, 2015

### jakkubu commented May 14, 2016

 Workaround for this issue was proposed here You can also add it in YAML header, on top of markdown file:  --- header-includes: - \newcommand{\hideFromPandoc}[1]{#1} \hideFromPandoc{ \let\Begin\begin \let\End\end } ---  and use \Begin{whatever} and \End{whatever} instead \begin{whatever} and \end{whatever} So @andreatta tables would look like this: \Begin(minipage}[b]{8mm} #table 1 \End{minipage} \Begin(minipage}[b]{8mm} #table 2 \End{minipage} 
Contributor Author

### yihui commented May 18, 2016

 @jakkubu Sounds like an interesting idea. Thanks!
referenced this issue May 18, 2016

### yihui added a commit to yihui/knitr that referenced this issue Sep 20, 2016

 add a block2 engine, using the trick provided in jgm/pandoc#2453 
this can close rstudio/bookdown#117, although a little more documentation should be provided
 966e28d 
referenced this issue Sep 22, 2016
Open

### memeplex commented Oct 5, 2016

 Why not officialize the Begin/End workaround by including it as a default header for tex and documenting it as a "parsed environment"?
Contributor Author

### yihui commented Oct 5, 2016

 That would be great, but it is not important to me now. I have added \let\Begin\begin in the preamble automatically in my use cases, and got some pretty environments in both HTML and PDF output, e.g. https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html

### memeplex commented Oct 6, 2016 • edited

 Thanks for the link @yihui, it looks really nice. Btw, I've suggested adding a fake tex command that instructs pandoc to parse its contents as markdown #3145, thus allowing reentering the parser in a more official and clean fashion. Do you think we should merge both issues?
Contributor Author

### yihui commented Oct 6, 2016

 @memeplex I definitely agree with you. It is just that I could wait any longer. My implementation details are totally hidden from users, so if some day what you envisioned becomes true, I can easily switch to the official approach without changing my top-level API.

### mathematicalcoffee added a commit to mathematicalcoffee/beamerposter-rmarkdown-example that referenced this issue Nov 20, 2016

 parse markdown in begin and end by using macros Begin and End like jg… 
…m/pandoc#2453
 2bf80e3 
referenced this issue Jan 20, 2017
Contributor

### ickc commented Jan 20, 2017

 I read your https://bookdown.org/yihui/bookdown/markdown-extensions-by-bookdown.html and sees some amsthm def. Have you tried my pandoc-amsthm mentioned in #1608? And just to cross-reference what I mentioned in #3368: I think the much better and stable way to do is via filter. There's a few mentioned in Pandoc Filters · jgm/pandoc Wiki, e.g.
Contributor

### ickc commented Jan 20, 2017

 Some comments on the hacks mentioned in this thread: The way to circumvent the pandoc's parsing of LaTeX environment is very "MultiMarkdown"-like. What I mean is it is very similar to the idea of MultiMarkdown's toggling of raw LaTeX commands. In the past (when I was from MultiMarkdown and not using pandoc yet), I have some success writing documents this way to target dual output (LaTeX and HTML). But ultimately I abandoned that approach because the source looks very ugly and hacky and difficult to maintain. (For example, a lot of text expansion might be needed to deal with the ugly syntaxes and glues and hacks.) The forte of pandoc not only lies in multiple input and output formats, but also about the filter system (allowed by the internal AST design). It takes some learning curve at the beginning, but ultimately really worth it. If some are new to filters, I suggest @sergiocorreia's panflute. It has a very mild learning curve and things can get done very quickly. Not to mention the ease in maintaining the code. i.e. clean source in markdown and python, clean output in any formats. Win-win.

### CooperWallace added a commit to CooperWallace/dotfiles that referenced this issue Mar 22, 2018

 Improve the Slide formatting, and add Markdown workaround 
The slides now fit better to the screen irregardless of how large they
originally are.

The issue that you cannot format text using markdown in a Tex
environment has been solved using a workaround documented here:

jgm/pandoc#2453 (comment)
 ba78881