Inline LaTeX with MMD 6

el
elw2u16
Posts: 17
Joined: Tue Nov 28, 2017 9:29 am
Platform: Mac

Tue Jul 03, 2018 10:15 am Post

Hi,
Thanks to those who have detailed some of the MMD6 changes. I'm using the

Code: Select all

````{=latex}
\begin{equation}
...
\end{equation}
````


for block LaTeX equations, figures, tables etc. and it's working well.

I want to use an inline LaTeX maths expression though, to put Greek symbols in my text, which I could do with the old LaTeX MMD style. However, using the backticks inline with text converts it to \texttt{} in the tex file and I get an associated error when compiling. I've tried 3, 4 and 5 backticks with the same result.

Has anyone done this successfully?

Thanks,
Emma

User avatar
nontroppo
Posts: 1066
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Tue Jul 03, 2018 2:51 pm Post

Why not use the Dollar syntax – double dollar for block and single for inline maths:

Code: Select all

An example of math within a paragraph --- ${e}^{i\pi }+1=0$
--- easy enough.

And an equation on it's own:

$${x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a}$$

That's it.

http://fletcher.github.io/MultiMarkdown-5/math.html

BTW single backticks are used for inline raw syntax, `\pi`{=latex} – pandoc documentation details this as the syntax is the same: http://pandoc.org/MANUAL.html#generic-raw-attribute

li
liz
Posts: 60
Joined: Sat Mar 25, 2017 6:40 pm
Platform: Win + iOS

Tue Jul 03, 2018 4:57 pm Post

What nontroppo said, and also

User avatar
nontroppo
Posts: 1066
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Wed Jul 04, 2018 1:13 am Post

For Greek I also just use XeLaTeX and unicode with a font that supports greek characters (with Alfred snippets auto-completing into greek for me during writing). I much prefer using unicode (i.e. Δδ) because I do not want to restrict my output to LaTeX alone, but to be robust to multiple output formats. i can compile to plain text, HTML, Libreoffice/Word, InDesign and never worry about some funky markup only one environment provides.

I didn't know that $ syntax was deprecated, but remember that MMD and Pandoc will convert $ and $$ into \( and \[ for you (well Pandoc does at least), so your LaTeX will still be 'clean'. And again, say you also need to export a copy to Word/LibreOffice, then it will convert the markdown delimiters into the correct maths markup for that as well. I try to use markdown and unicode in preference to any output-specific markup wherever possible.

In fact, if you are using styles, you will never even see this markup because Scrivener will insert it for you...

el
elw2u16
Posts: 17
Joined: Tue Nov 28, 2017 9:29 am
Platform: Mac

Wed Jul 04, 2018 12:34 pm Post

Thanks for the suggestions. I can confirm that:

  • $ and $$ do not work in MMD6 (for me, anyway)
  • Using a single backtick does not work inline (I still get the \texttt issue)
  • Using \\( and \\) does work to give inline math using MMD6 to LaTeX.

Thanks again,
Emma

User avatar
nontroppo
Posts: 1066
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Wed Jul 04, 2018 1:35 pm Post

Hm, $ and $$ to delimit maths work for me in Pandoc V2.21 or MMD 6.32 (Pandoc converts $ and $$ to \( and \[ but not MMD):

Code: Select all

❯ multimarkdown -t latex
An example of math within a paragraph --- ${e}^{i\pi }+1=0$
--- easy enough.

And an equation on it's own:

$${x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a}$$

That's it.

^D

An example of math within a paragraph --- ${e}^{i\pi }+1=0$
--- easy enough.

And an equation on it's own:

$${x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a}$$

That's it.

~
❯ pandoc -t latex
An example of math within a paragraph --- ${e}^{i\pi }+1=0$
--- easy enough.

And an equation on it's own:

$${x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a}$$

That's it.


^D

An example of math within a paragraph --- \({e}^{i\pi }+1=0\) --- easy
enough.

And an equation on it's own:

\[{x}_{1,2}=\frac{-b\pm \sqrt{{b}^{2}-4ac}}{2a}\]

That's it.


But even with $ and $$ the MMD output tex builds just fine:
Screen Shot 2018-07-04 at 21.32.51.png
Screen Shot 2018-07-04 at 21.32.51.png (10.6 KiB) Viewed 1954 times



The single backtick raw latex is also working for me for escaping greek characters, at least from the command line so something else is triggering the conversion to teletype???:

Code: Select all

❯ multimarkdown -t latex

Here is a test \delta to see if escaping `\delta`{=latex} works

^D
Here is a test \textbackslash{}delta to see if escaping \delta works


el
elw2u16
Posts: 17
Joined: Tue Nov 28, 2017 9:29 am
Platform: Mac

Wed Jul 04, 2018 3:17 pm Post

Hi,

I don't use the command line - I compile in Scrivener for MMD to LaTeX.

Copying and pasting what you have done using the backtick into my document gives:

Code: Select all

Here is a test \textbackslash{}delta to see if escaping \delta works


The dollar signs now work, although I've just updated my LaTeX distribution so that might have had some effect...

Thanks,
Emma

li
liz
Posts: 60
Joined: Sat Mar 25, 2017 6:40 pm
Platform: Win + iOS

Wed Jul 04, 2018 6:22 pm Post

\delta (or \alpha, etc.) isn't a LaTeX command unless you're in math mode. This is why you need to either use the textgreek package or unicode+XeLaTeX.
It's possible that nontroppo's LaTeX installation is automatically putting the missing math mode delimiters around \alpha, but MMD understands that it's not a LaTeX command and instead renders it as text.

User avatar
nontroppo
Posts: 1066
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Thu Jul 05, 2018 3:39 am Post

elw2u16 wrote:I don't use the command line - I compile in Scrivener for MMD to LaTeX.

Copying and pasting what you have done using the backtick into my document gives:


That is giving the same output as the command line, which I hope it should (well, at least Scrivener 3.03 that has MMD 6 by default), so this is working I think...

Liz: yes you are absolutely right, though the example was just as a quick demonstration that ``{=latex} was working for MMD 6...