remark icon indicating copy to clipboard operation
remark copied to clipboard

how to use katex environments like \begin{matrix}

Open floswald opened this issue 7 years ago • 6 comments

hi there,

I have this index.html:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>{{title}}</title>
  {{{style}}}
  <script src="remark.min.js"></script>  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-9eLZqc9ds8eNjO3TmqPeYcDj8n+Qfa4nuSiGYa6DjLNcv9BtN69ZIulL9+8CqC9Y" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-K3vbOmF2BtaVai+Qk37uypf7VrgBubhQreNQe9aGsz9lB63dIFiQVlJbr92dw2Lx" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-kmZOZB5ObwgQnS/DuDg6TScgOiWWBiVt0plIRkZCmE6rDZGrEOQeHM5PcHi+nyqe" crossorigin="anonymous"
    onload="renderMathInElement(document.body);"></script>

  <script>
    function create() {
      var renderMath = function() {
        // renderMathInElement(document.body);
        // or if you want to use $...$ for math,
        renderMathInElement(document.body, {
          delimiters: [
            {left: "$$", right: "$$", display: true},
            {left: "$", right: "$", display: false},
            {left: "\\(", right: "\\)", display: false},
            {left: "\\[", right: "\\]", display: true}
            // {left: "\\begin{equation}", right: "\\end{equation}", display: true},
            // {left: "\\begin{aligned}", right: "\\end{aligned}", display: true}
          ]
        });
      }
      remark.macros.scale = function (percentage) {
        var url = this;
        return '<img src="' + url + '" style="width: ' + percentage + '" />';
      };
      return remark.create({
        {{{source}}},
        ratio: '16:9',
        highlightLines: true,
        countIncrementalSlides: false,
        highlightStyle: 'github'
      },renderMath);
    }
  </script>
</head>
<body onload="slideshow = create()">
</body>
</html>

and I have this .md

# The basics

$\alpha$

$$\alpha + \beta$$

$$
\begin{matrix}
   a & b \\
   c & d
\end{matrix}
$$

but the environment stuff never works:

screenshot 2018-12-13 16 06 33

any ideas?

floswald avatar Dec 13 '18 15:12 floswald

I ran into a similar problem recently that had to do with backslash escaping weirdness.

Note that when it gets rendered, the \\ separating the two lines becomes a single \. Thus, in your markdown, your line separator \\ should instead be \\\, and then it'll work right.

rhinopotamus avatar Jan 28 '19 22:01 rhinopotamus

hey, thanks for that hint. i get a bit further now, but still weird.

# The basics

$\alpha$

\\[\alpha + \beta\\]

\\[\begin{array}{cc}
   a & b \\\
   c & d
\end{array}\\]
screenshot 2019-01-29 09 37 49

floswald avatar Jan 29 '19 08:01 floswald

Many problems occur when I just tried to type several simple formulae. like subscripts $$\sigma_x = \frac{1}{2}$$ will not be displayed correctly.

LiukDiihMieu avatar Oct 12 '19 14:10 LiukDiihMieu

I think you need to escape the underscore.

Try

\sigma_x

On Sat 12 Oct 2019 at 16:49, LiukDiihMrau [email protected] wrote:

Many problems occur when I just tried to type several simple formulae. like subscripts $$\sigma_x = \frac{1}{2}$$ will not be displayed correctly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gnab/remark/issues/551?email_source=notifications&email_token=AAHZM5TGWQPMOKG4DHQC7M3QOHPX3A5CNFSM4GKHJOMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBCBBAY#issuecomment-541331587, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZM5THE3PQNEMJXQBQOIDQOHPX3ANCNFSM4GKHJOMA .

floswald avatar Oct 12 '19 15:10 floswald

Also I think I remember that you need to put multi line latex environments on one markdown line inside $$ delims. Linebreaks after a \ for example will not work. That’s what I found with R xaringan package at least (that uses remark)

On Sat 12 Oct 2019 at 17:15, Florian Oswald [email protected] wrote:

I think you need to escape the underscore.

Try

\sigma_x

On Sat 12 Oct 2019 at 16:49, LiukDiihMrau [email protected] wrote:

Many problems occur when I just tried to type several simple formulae. like subscripts $$\sigma_x = \frac{1}{2}$$ will not be displayed correctly.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gnab/remark/issues/551?email_source=notifications&email_token=AAHZM5TGWQPMOKG4DHQC7M3QOHPX3A5CNFSM4GKHJOMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBCBBAY#issuecomment-541331587, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHZM5THE3PQNEMJXQBQOIDQOHPX3ANCNFSM4GKHJOMA .

floswald avatar Oct 12 '19 15:10 floswald

I have run into some issues where in some of my slides, $$\sigma_{x + 1} = \frac{1}{2}$$ works, but in others I need to escape the underscore as in $$\sigma\_{x + 1} = \frac{1}{2}$$

ianfiske avatar Jan 21 '20 00:01 ianfiske