Skip to content
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

Closed
yihui opened this issue Oct 15, 2015 · 11 comments
Closed

A markdown_in_tex_blocks extension #2453

yihui opened this issue Oct 15, 2015 · 11 comments

Comments

@yihui
Copy link
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
Copy link

+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
Copy link

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
Copy link
Contributor Author

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
this can close rstudio/bookdown#117, although a little more documentation should be provided
@memeplex
Copy link

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
Copy link
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
Copy link

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
Copy link
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.

@ickc
Copy link
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
Copy link
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
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)
@sinisterstumble
Copy link

The extension raw_attribute solves this. (ignore the >)

> ```{=latex}
> \begin{center}
> ```
> Remember to check **Appendix A** for additional resources references and detailed explanations.
> ```{=latex}
> \end{center}
> ```

becomes

\begin{note}
Remember to check \textbf{Appendix A} for additional resources references and detailed explanations.
\end{note}

@jgm
Copy link
Owner

jgm commented May 27, 2024

Yes, I think using raw attributes is the solution here.

@jgm jgm closed this as completed May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants