public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Markdown in LaTeX blocks?
@ 2015-10-14 20:48 Yihui Xie
       [not found] ` <33a034bb-fc38-4df2-b8b1-8934e3c76358-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Yihui Xie @ 2015-10-14 20:48 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 851 bytes --]

Hi,

I see there is a Markdown extension "markdown_in_html_blocks", and I'm 
wondering if it is possible to do the similar thing for raw LaTeX blocks, 
e.g. convert

\begin{foo}
This is **Markdown**.
\end{foo}

to

\begin{foo}
This is \textbf{Markdown}.
\end{foo}

Thanks,
Yihui

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/33a034bb-fc38-4df2-b8b1-8934e3c76358%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 1456 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found] ` <33a034bb-fc38-4df2-b8b1-8934e3c76358-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2015-10-15  3:37   ` John MacFarlane
       [not found]     ` <20151015033741.GA2874-jF64zX8BO08aTFSqC7bH4WZHpeb/A1Y/@public.gmane.org>
  2017-06-23  8:08   ` lucian enache
  1 sibling, 1 reply; 8+ messages in thread
From: John MacFarlane @ 2015-10-15  3:37 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

You might like this:
https://randomdeterminism.wordpress.com/2011/01/09/markdowntopdf/

+++ Yihui Xie [Oct 14 15 13:48 ]:
>   Hi,
>   I see there is a Markdown extension "markdown_in_html_blocks", and I'm
>   wondering if it is possible to do the similar thing for raw LaTeX
>   blocks, e.g. convert
>   \begin{foo}
>   This is **Markdown**.
>   \end{foo}
>   to
>   \begin{foo}
>   This is \textbf{Markdown}.
>   \end{foo}
>   Thanks,
>   Yihui
>
>   --
>   You received this message because you are subscribed to the Google
>   Groups "pandoc-discuss" group.
>   To unsubscribe from this group and stop receiving emails from it, send
>   an email to [1]pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To post to this group, send email to
>   [2]pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
>   To view this discussion on the web visit
>   [3]https://groups.google.com/d/msgid/pandoc-discuss/33a034bb-fc38-4df2-
>   b8b1-8934e3c76358%40googlegroups.com.
>   For more options, visit [4]https://groups.google.com/d/optout.
>
>References
>
>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   2. mailto:pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   3. https://groups.google.com/d/msgid/pandoc-discuss/33a034bb-fc38-4df2-b8b1-8934e3c76358-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org?utm_medium=email&utm_source=footer
>   4. https://groups.google.com/d/optout


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found]     ` <20151015033741.GA2874-jF64zX8BO08aTFSqC7bH4WZHpeb/A1Y/@public.gmane.org>
@ 2015-10-15  3:45       ` Yihui Xie
       [not found]         ` <CANROs4cVZKdWc-Sh_HYt_S=fy2LzS6rd8PF41Z5GbZKJkwt=vw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Yihui Xie @ 2015-10-15  3:45 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Interesting. I guess that is also simple to implement in R. I'll try
it later. Thanks!

Is there a particular reason that we only have the
markdown_in_html_blocks extension but not markdown_in_tex_blocks?

Regards,
Yihui
--
Yihui Xie <xieyihui-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Web: http://yihui.name


On Wed, Oct 14, 2015 at 10:37 PM, John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
> You might like this:
> https://randomdeterminism.wordpress.com/2011/01/09/markdowntopdf/
>
> +++ Yihui Xie [Oct 14 15 13:48 ]:
>>
>>   Hi,
>>   I see there is a Markdown extension "markdown_in_html_blocks", and I'm
>>   wondering if it is possible to do the similar thing for raw LaTeX
>>   blocks, e.g. convert
>>   \begin{foo}
>>   This is **Markdown**.
>>   \end{foo}
>>   to
>>   \begin{foo}
>>   This is \textbf{Markdown}.
>>   \end{foo}
>>   Thanks,
>>   Yihui


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found]         ` <CANROs4cVZKdWc-Sh_HYt_S=fy2LzS6rd8PF41Z5GbZKJkwt=vw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-10-15 17:29           ` John MACFARLANE
       [not found]             ` <20151015172910.GA85155-4kKid1p5UN4xFjuZnxJpBp3lxR28IOakuDuwTybUTCk@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: John MACFARLANE @ 2015-10-15 17:29 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

+++ Yihui Xie [Oct 14 15 22:45 ]:
>Interesting. I guess that is also simple to implement in R. I'll try
>it later. Thanks!
>
>Is there a particular reason that we only have the
>markdown_in_html_blocks extension but not markdown_in_tex_blocks?

Not really.  Maybe this would make sense to add.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found]             ` <20151015172910.GA85155-4kKid1p5UN4xFjuZnxJpBp3lxR28IOakuDuwTybUTCk@public.gmane.org>
@ 2015-10-15 17:59               ` Yihui Xie
       [not found]                 ` <CANROs4eAAAjSOD+WjfS5gEvyHhzQ6yFP9t3WU6VgkUS2abX5gg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
  0 siblings, 1 reply; 8+ messages in thread
From: Yihui Xie @ 2015-10-15 17:59 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Okay, just filed a feature request at https://github.com/jgm/pandoc/issues/2453

Regards,
Yihui
--
Yihui Xie <xieyihui-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Web: http://yihui.name


On Thu, Oct 15, 2015 at 12:29 PM, John MACFARLANE <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> wrote:
> +++ Yihui Xie [Oct 14 15 22:45 ]:
>>
>> Interesting. I guess that is also simple to implement in R. I'll try
>> it later. Thanks!
>>
>> Is there a particular reason that we only have the
>> markdown_in_html_blocks extension but not markdown_in_tex_blocks?
>
>
> Not really.  Maybe this would make sense to add.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found]                 ` <CANROs4eAAAjSOD+WjfS5gEvyHhzQ6yFP9t3WU6VgkUS2abX5gg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
@ 2015-10-17 23:49                   ` Melroch
  0 siblings, 0 replies; 8+ messages in thread
From: Melroch @ 2015-10-17 23:49 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

[-- Attachment #1: Type: text/plain, Size: 3235 bytes --]

There is a workaround:

Put this at the top of your document:

````
\newcommand{\hideFromPandoc}[1]{#1}
\hideFromPandoc{
    \let\Begin\begin
    \let\End\end
}
````

Then in your document:

````
\Begin{center}

Here is *markdown*!

\End{center}
````

Note the capitalization and empty lines!

The newcommand creates a dummy command which stops pandoc from breaking the
LaTeX inside its argument.
The real magic is the \let commands which make LaTeX perfectly happy with
\Begin and \End as synonyms of \begin and \end while pandoc just sees two
inline commands rather than a block. That's why you need the empty lines
around them to really get a block in LaTeX.

If you want to generate both LaTeX and HTML from the same source you can
put a div inside the environment:

````
\Begin{center}
<div class="center">
Here is *markdown*!
</div>
\End{center}
````

No extra blank lines are needed then but you will get some extra empty
`<p></p>` elements which you may want to remove from your HTML.

The eqhivalent for commands is like this:

````
\textsf<span class="sans">Here is *markdown*</span>
````

It looks totally weird but it works because the LaTeX writer puts braces
around the span content. If you are not going to produce HTML you don't
even need the `class="sans"`!

I hope this helps.

/bpj
Den 15 okt 2015 20:00 skrev "Yihui Xie" <xieyihui-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:

> Okay, just filed a feature request at
> https://github.com/jgm/pandoc/issues/2453
>
> Regards,
> Yihui
> --
> Yihui Xie <xieyihui-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Web: http://yihui.name
>
>
> On Thu, Oct 15, 2015 at 12:29 PM, John MACFARLANE <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org>
> wrote:
> > +++ Yihui Xie [Oct 14 15 22:45 ]:
> >>
> >> Interesting. I guess that is also simple to implement in R. I'll try
> >> it later. Thanks!
> >>
> >> Is there a particular reason that we only have the
> >> markdown_in_html_blocks extension but not markdown_in_tex_blocks?
> >
> >
> > Not really.  Maybe this would make sense to add.
>
> --
> You received this message because you are subscribed to the Google Groups
> "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/pandoc-discuss/CANROs4eAAAjSOD%2BWjfS5gEvyHhzQ6yFP9t3WU6VgkUS2abX5gg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhAO-Yv3s5nx-OsrkH7W_fKi5t%2BXh8WJ-r%3DO-Ksk7NUxVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #2: Type: text/html, Size: 5133 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found] ` <33a034bb-fc38-4df2-b8b1-8934e3c76358-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  2015-10-15  3:37   ` John MacFarlane
@ 2017-06-23  8:08   ` lucian enache
       [not found]     ` <ba933a06-e6e4-4692-a0d6-31aea454ee41-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  1 sibling, 1 reply; 8+ messages in thread
From: lucian enache @ 2017-06-23  8:08 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2417 bytes --]

Hi, Sorry to revive this old topic, but I have an issue when trying to wrap 
markdown with minipages as follows:


This piece works correctly

\Begin{minipage}{\textwidth}

    ###Rockets

    \Begin{minipage}{0.45\textwidth}

        \vspace{0pt}

        What do you know about rockets:

        - How rockets work?
        - What would it take to ensure that rockets are safe?
        - What types of rockets do you know?

    \End{minipage}

    \hspace{0.05\linewidth}

    \Begin{minipage}{0.45\textwidth}

        \vspace{0pt}

        
![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Soyuz_rocket_ASTP.jpg/1200px-Soyuz_rocket_ASTP.jpg)

    \End{minipage}

\End{minipage}


Where as when using top alignment in the minipage, the snippet stops 
working and pandoc cannot compile it.

\Begin{minipage}[t]{\textwidth}

    ###Rockets

    \Begin{minipage}[t]{0.45\textwidth}

        \vspace{0pt}

        What do you know about rockets:

        - How rockets work?
        - What would it take to ensure that rockets are safe?
        - What types of rockets do you know?

    \End{minipage}

    \hspace{0.05\linewidth}

    \Begin{minipage}[t]{0.45\textwidth}

        \vspace{0pt}

        
![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Soyuz_rocket_ASTP.jpg/1200px-Soyuz_rocket_ASTP.jpg)

    \End{minipage}

\End{minipage}

So it is mostly about adding the *[t] *to the minipage, any ideas on how to 
get it working ?

On Wednesday, October 14, 2015 at 10:48:00 PM UTC+2, Yihui Xie wrote:
>
> Hi,
>
> I see there is a Markdown extension "markdown_in_html_blocks", and I'm 
> wondering if it is possible to do the similar thing for raw LaTeX blocks, 
> e.g. convert
>
> \begin{foo}
> This is **Markdown**.
> \end{foo}
>
> to
>
> \begin{foo}
> This is \textbf{Markdown}.
> \end{foo}
>
> Thanks,
> Yihui
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ba933a06-e6e4-4692-a0d6-31aea454ee41%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[-- Attachment #1.2: Type: text/html, Size: 3903 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Markdown in LaTeX blocks?
       [not found]     ` <ba933a06-e6e4-4692-a0d6-31aea454ee41-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2017-06-23 11:55       ` BP Jonsson
  0 siblings, 0 replies; 8+ messages in thread
From: BP Jonsson @ 2017-06-23 11:55 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw, lucian enache

Den 2017-06-23 kl. 10:08, skrev lucian enache:
> Hi, Sorry to revive this old topic, but I have an issue when trying to wrap
> markdown with minipages 


No worries. There are some subtle problems in how pandoc parses LaTeX.
I happen to have spent an inordinate amount of time xto work around them.
Generally it is a good idea to produce a document with 
`pandoc -so test.ltx input.md` to see what pandoc makes of your source.

There are three problems:

1.  Pandoc gets confused by the `[t]` because of the square
    brackets. It sees `\Begin` as an ordinary command and expects
    any optional argument to be the first one. Thus it doesn't
    see `[t]` and what follows it as arguments to `\Begin`. The
    workaround is to define a wrapper environment which takes the
    adjustment as a mandatory argument:

        \newenvironment{PosMinipage}[2]{\minipage[#1]{#2}}{\endminipage}

        \Begin{PosMinipage}{t}{0.45\textwidth}

    The syntax for wrapping an environment in another environment
    looks weird, but that's the way it works. Internally LaTex
    implements an environment through a pair of commands like
    `\minipage` and `\endminipage`.

2.  The indentation makes Pandoc see the indented paragraphs as
    code blocks. Remove the indentation except in list
    continuation paragraphs, if any.

    <http://pandoc.org/MANUAL.html#indented-code-blocks>

    <http://pandoc.org/MANUAL.html#the-four-space-rule>

3.  For some reason latex barfs at the `\centering` which pandoc
    inserts in the figure environment. Since you don't have any
    caption anyway I suggest manually wrapping the image link in
    a `center` environment and add a non-breaking space after the
    image link so that pandoc doesn't produce a figure
    environment. (Actually the `center` is probably not needed
    here as the image seems to take up the whole available width
    in the minipage anyway.)

        \Begin{center}
        ![](https://example.com/path/to/image.jpg)&nbsp;
        \End{center}

Finally the following works (minus the code block fences of
course!):

``` {.pandoc_markdown}
\newcommand{\Dummy}[1]{#1}
\Dummy{\let\Begin\begin}
\Dummy{\let\End\end}
\Dummy{\newenvironment{PosMinipage}[2]{\minipage[#1]{#2}}{\endminipage}}

\Begin{PosMinipage}{t}{\textwidth}

###Rockets

\Begin{PosMinipage}{t}{0.45\textwidth}

\vspace{0pt}

What do you know about rockets:

- How rockets work?
- What would it take to ensure that rockets are safe?
- What types of rockets do you know?

\End{PosMinipage}

\hspace{0.05\linewidth}

\Begin{PosMinipage}{t}{0.45\textwidth}

\vspace{0pt}


\Begin{center}
![](https://upload.wikimedia.org/wikipedia/commons/thumb/2/27/Soyuz_rocket_ASTP.jpg/1200px-Soyuz_rocket_ASTP.jpg)&nbsp;
\End{center}


\End{PosMinipage}

\End{PosMinipage}
```

/bpj


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-06-23 11:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-14 20:48 Markdown in LaTeX blocks? Yihui Xie
     [not found] ` <33a034bb-fc38-4df2-b8b1-8934e3c76358-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2015-10-15  3:37   ` John MacFarlane
     [not found]     ` <20151015033741.GA2874-jF64zX8BO08aTFSqC7bH4WZHpeb/A1Y/@public.gmane.org>
2015-10-15  3:45       ` Yihui Xie
     [not found]         ` <CANROs4cVZKdWc-Sh_HYt_S=fy2LzS6rd8PF41Z5GbZKJkwt=vw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-15 17:29           ` John MACFARLANE
     [not found]             ` <20151015172910.GA85155-4kKid1p5UN4xFjuZnxJpBp3lxR28IOakuDuwTybUTCk@public.gmane.org>
2015-10-15 17:59               ` Yihui Xie
     [not found]                 ` <CANROs4eAAAjSOD+WjfS5gEvyHhzQ6yFP9t3WU6VgkUS2abX5gg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-10-17 23:49                   ` Melroch
2017-06-23  8:08   ` lucian enache
     [not found]     ` <ba933a06-e6e4-4692-a0d6-31aea454ee41-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2017-06-23 11:55       ` BP Jonsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).