New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A markdown_in_tex_blocks extension #2453

Open
yihui opened this Issue Oct 15, 2015 · 9 comments

Comments

Projects
None yet
6 participants
@yihui
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!

@jgm jgm added the enhancement label Oct 20, 2015

@andreatta

This comment has been minimized.

Show comment
Hide comment
@andreatta

andreatta 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}

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}

@jakkubu

This comment has been minimized.

Show comment
Hide comment
@jakkubu

jakkubu 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}

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}
@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui May 18, 2016

Contributor

@jakkubu Sounds like an interesting idea. Thanks!

Contributor

yihui commented May 18, 2016

@jakkubu Sounds like an interesting idea. Thanks!

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

@sergiocorreia sergiocorreia referenced this issue Sep 22, 2016

Open

Idea #1

@memeplex

This comment has been minimized.

Show comment
Hide comment
@memeplex

memeplex 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"?

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"?

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui Oct 5, 2016

Contributor

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

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@memeplex

memeplex Oct 6, 2016

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?

memeplex commented Oct 6, 2016

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?

@yihui

This comment has been minimized.

Show comment
Hide comment
@yihui

yihui Oct 6, 2016

Contributor

@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.

Contributor

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.

@ickc

This comment has been minimized.

Show comment
Hide comment
@ickc

ickc Jan 20, 2017

Contributor

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

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.

@ickc

This comment has been minimized.

Show comment
Hide comment
@ickc

ickc Jan 20, 2017

Contributor

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.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment