inline mathematics

Ray Brock's Avatar

Ray Brock

25 Jun, 2018 11:33 PM

I can't believe I didn't notice this before, but in-line math is not rendering...nor are multi-line math environments...

For example this paragraph:

is the equation for a straight line. Do you remember some time in your past algebraic life saying, "y equals m x plus b" ...$y=mx + b$? Here, "$y$" is our distance, $x$; (confusingly) $x$ is our time difference, $t$; and $b$ (the slope in the equation) is our average velocity, $\langle v \rangle$.

renders just like that... with the $ exposed.

Meanwhile,

$$
\begin{align}
\langle v \rangle &= \frac{x - x_0}{t - t_0} \nonumber \\
\langle v \rangle \times (t - t_0) &= x - x_0 \nonumber \\
x &= x_0 + \langle v \rangle ({t - t_0}), \text{ which a the symbolic statement of:} \nonumber \\
\text{some-where} &= \text{Comerica} + 60~\text{mph}\times (\text{some-time}-\text{4pm}) \nonumber
\end{align}
$$

renders all on one line.

Other math is fine.

Am I missing something somehow? I don't have this problem in any other markdown editor...and believe me, I own them all!

thanks!
Ray

  1. Support Staff 1 Posted by Fletcher on 26 Jun, 2018 12:39 AM

    Fletcher's Avatar

    I don't have any trouble with the first paragraph.

    The slashes in the second example are being escaped, so you can fix for
    now by doubling up (e.g. `\\\\`). I'll look at that -- don't see any
    problem with changing that for math environment, but let me make sure
    I'm not missing anything.

    Be sure to refresh preview to trigger MathJax to re-run.

    F-

  2. Support Staff 2 Posted by Fletcher on 26 Jun, 2018 01:01 AM

    Fletcher's Avatar

    Actually, it isn't that the backslashes are escaping, it's treating the last one as a line break \\n.

  3. Support Staff 3 Posted by Fletcher on 26 Jun, 2018 01:17 AM

    Fletcher's Avatar

    Oops -- spoke too soon. The reason that the interior markup was wrong was that what you pasted (the multiline section) isn't math -- you can't have whitespace immediately "inside" the markup:

    $$foo
    bar$$
    

    not

    $$
    foo
    bar
    $$
    

    When I fix that, it seems to work properly for me.

  4. 4 Posted by Raymond Brock on 26 Jun, 2018 01:04 PM

    Raymond Brock's Avatar

    Thanks for your quick reply. Okay…some md apps do require that the $$ snuggle up to the first line, I’d forgotten.. Some don’t care. Those of us who write LaTeX forever can do either in that world.

    As for the first paragraph - the inline math - I swear that sometimes it works and sometimes it doesn’t but I didn’t say that since it’s too crazy to contemplate and I figured I was just wrong. On my home computer, I’m seeing it complete most, but not all in-line math. See the attached screen shots

    — BTW I also notice that I cannot seem to comment out a paragraph with <!— —> ? more attachments.

    Sorry to fill your box…

    Ray

    [cid:02A1AC0D-7C80-4C37-B3E7-DD2DDDFEE499][cid:89E5141E-7863-4C9C-A493-7645E76448B8][cid:4E489697-4C27-4050-AE01-5B564C669D7B]
    [cid:09D7003E-6544-4FFA-815E-4F2846D8E66F]
    On Jun 25, 2018, at 9:17 PM, Fletcher <[email blocked]<mailto:[email blocked]>> wrote:

  5. Support Staff 5 Posted by Fletcher on 26 Jun, 2018 07:52 PM

    Fletcher's Avatar

    > Okay…some md apps do require that the $$
    > snuggle up to the first line, I’d forgotten.. Some don’t care.

    MMD does not allow space inside the math delimiters (at least the
    `$...$` and `$$...$$` variants -- the `\[...\]` and `\(...\)` are more
    flexible since they are unlikely to be used by accident). Some apps may
    only pretend to use MMD, or some may use really old versions that do not
    have all of the bug fixes from the years...

    MathJax does not necessarily disallow said spaces -- it doesn't look for
    MMD math, but instead looks for anything that seems to be LaTeX math.
    So it can recognize something that looks like MMD math, but isn't. But
    that can lead to parsing mismatch, which is what happened in your
    multi-line example.

    As for the inline math, the examples you use that seem not work are
    surrounded by quotes. But not regular quotes -- you used "smart quotes"
    in the MMD text. The `$...$` syntax requires "outside" space and the
    absence of "inside" space. Standard ASCII punctuation can replace the
    outside space, but not arbitrary UTF punctuation (there are too many
    possibilities without building a true UTF parser). These are math:

    $x + y^\pi$
    "$x + y^\pi$"

    This is not math:

    “$x+y^\pi$”

    But this would be math:

    “ $x+y^\pi$ ”

    MMD does much better when you stick to straight quotes in the input
    text, and let it provide the smart quotes in the output.

    As for comments -- you started a comment in one paragraph, and finished
    it in another paragraph. So they can't be joined to create an HTML block.

    Either use a single paragraph:

    <!-- foo bar -->

    Or keep the comment markers as separate blocks:

    <!--

    foo

    bar

    -->

    Hope this helps,

    Fletcher

  6. 6 Posted by Raymond Brock on 26 Jun, 2018 08:40 PM

    Raymond Brock's Avatar

    hi
    Thanks for your quick response. I see how the comment business works now. I’ve been using the regular HTML comment tags for a long time inside of markdown apps, but I think mostly on one-line things. It works there. So I get it.

    On the inline math, I’m not so sure that it’s only about the quotes. Notice that the first two lines in the attachment I sent don’t involve quotation marks. Attached here are some more that won’t render that aren’t in a list… I’ve got them throughout the document. They render fine in a browser, and frankly in other markdown apps…but I want to use Multimarkdown Composer so I keep coming back to see if it’s better at this… I’m afraid that there’s omething’s funky about MathJax I’m pretty sure.

    thanks
    Ray

    [cid:39B879CA-F979-48B3-B833-880C83A29C3C][cid:C92D7FD0-C5AF-4A2B-A3AB-933FA24C30D2][cid:72B66BF9-CBE0-4066-9ABE-82013D407CC6][cid:8CBC6568-C963-49F7-84B1-89B475D39045][cid:E6A8DF8B-6541-4717-A7C1-3DDCE68D9EF4][cid:A2114C44-A88E-4D23-9C7A-CA28157893EC]

    On Jun 26, 2018, at 3:53 PM, Fletcher <[email blocked]<mailto:[email blocked]>> wrote:

  7. Support Staff 7 Posted by Fletcher on 26 Jun, 2018 08:44 PM

    Fletcher's Avatar

    The screenshots are pretty small/low resolution. It's more helpful to
    send the actual relevant section of the source text that you're having
    trouble with.

  8. 8 Posted by Raymond Brock on 26 Jun, 2018 08:52 PM

    Raymond Brock's Avatar

    Sorry. Mail must have done something… are these better? I see that it defaulted to “small” for Image Size…now it’s Actual Size. Source and render… I’ve also attached some screen shots from when the markdown is processed into a browser, it’s eventual home. It’s always fine in the final product. It just misbehaves in the MC rendering.

    The source is also attached.

    thanks
    Ray

    On Jun 26, 2018, at 4:44 PM, Fletcher <[email blocked]<mailto:[email blocked]>> wrote:

  9. Support Staff 9 Posted by Fletcher on 26 Jun, 2018 09:17 PM

    Fletcher's Avatar

    I suppose it's better, but let's step back.

    What I'm getting is a long document with tons of math all over the
    place. Some of it is properly formatted, some of it is not.

    I then also have a bunch of small screenshots, some of which look fine,
    and some don't. But it's not always clear which are screenshots of
    preview and which are text. (if any)

    1. Are you refreshing the preview if you see something that you think
    should appear as math, but isn't? When I refresh the preview of your
    document, it *seems* to work properly, but perhaps I am not looking in
    the proper places.

    2. If you are refreshing the preview, and still not getting the expected
    result, it would be more helpful to just send me the relevant sentence
    or two as a separate text file, after confirming that this "minimum
    (non-)working example" still doesn't work. Working with such a long
    document means I am looking for a needle in a haystack when I am not
    even sure that the needle is there to be found (back to question #1 above).

    For example, one of your images seems to match this section of text:

    Now add them up for the total distance fallen as time
    increases: the first unit of time, 1. The second unit of time
    $1+3=4$. The third unit of time, $1+3+5=9$, and so on.
    1, 4, 9... are the perfect squares of the time intervals,
    1, 2, 3... Seeing falling

    When I refresh the preview after editing, this formats properly, but in
    the screenshot you sent I see the original `$` characters.

    F-

  10. 10 Posted by Raymond Brock on 26 Jun, 2018 10:09 PM

    Raymond Brock's Avatar

    Sorry, man. I was trying to be pretty complete:

    o I sent you pictures of both the paragraphs in the MC source and requisite paragraphs from the MC rendering. They are in pairs and you can match the words in each to see that.

    o I also added 2 I think of the same areas of the document as they render when I go through the whole jekyl process…showing that everything looks fine. So if you see nicely formatted text and math…that’s from safari, not MC. If you see non-rendered math…that’s in MC.

    You might have to double click or Quick Look on the images in your mail app because they’re quite big… when I double click on them.

    I thought you wanted the document. Sorry. All of it is properly formatted math since I know that it looks fine as http rendering in safari. Here is a link to an uploaded, earlier version of this document. The parts I’m quibbling about were not changed since then:

    https://qstbb.pa.msu.edu/ed/lectures/L4_motion19/

    1. Yes. I control-R multiple times before giving up and before attaching things. That’s what you mean, right?

    2. Okay. Here’s a different source paragraph:

    ----------------------------------

    The next thing that he found was not quite the case, but here he was again, very clever. Look at (b) which has some additional markings. The height that the bob starts from at C, $y_C$, is the same as the height that the pendulum goes to at D, namely $y_C=y_D$. Furthermore, this height is obtained back and forth as the pendulum repeats its motion.

    ----------------------------------

    It’s one of the pairs I sent you, but I’ve now attached a screen shot of both sides of the MC window in one. Top of left and bottom of right are the matches. Double click on it to magnify it.

    [cid:12A7BA35-FE1F-4FB9-8A35-40BC176304D4]

    I also have attached a screen shot from Typora for that same paragraph. No problem.
    [cid:C38E65B4-9CC8-424B-9ACB-D940E03BECB3]

    As for your “for example” comment… No clue. If those sentence work for you, that makes no sense.

    So I went to my macbook pro and looked at the same file…and, seriously, it’s fine! It renders just fine on the portable but is screwing up on my imac…two computers, side by side.

    That. Makes. no. sense. Remember I worried that I would sound like an idiot that it seemed to come and go? Well, I’m not an idiot. The same version of MC 4.4.4 on two computers with entirely different behavior for mathematics.

    Could there be different MathJax instances? No…not for my ultimate rendering. I invoke it with:

    <script type="text/javascript"
       src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
     </script>

    which I presume you’re somehow doing in MC. (I’m recalling the MathJax hosting problem of last year.)

    Could it be the css preview file? Doesn’t seem to be, but that’s a difference between the two computers.

    So I’m at a loss now. When I emailed you this morning, I was on a newer imac at home. I work on three computers. Of course I’ll check there when I go back tonight.

    Ray

    On Jun 26, 2018, at 5:17 PM, Fletcher <[email blocked]<mailto:[email blocked]>> wrote:

  11. Support Staff 11 Posted by Fletcher on 26 Jun, 2018 10:50 PM

    Fletcher's Avatar

    In the side by side image, notice the `[^pend]: ...` in the second
    paragraph under the image, implying that the footnote reference failed
    to parse.

    That shouldn't be happening, and doesn't happen when I load your
    document on my computer.

    Did you disable MultiMarkdown and restrict Composer to regular Markdown?
     Check MMD preferences.

    > All of it is properly
    > formatted math since I know that it looks fine as http rendering in
    > safari.

    Not a valid if..then statement, as mentioned previously. MathJax != MMD
    math. Your best bet for reliably handling math is to ensure that every
    instance is valid MMD math. That ensures the proper HTML output for any
    special characters inside the math span, and helps ensure that the
    proper delimiters are given to MathJax in the preview. Sometimes
    MathJax will work just fine with invalid math, but as you're
    experiencing, sometimes it can get you into trouble.

    For example:

    <aside class="myaside"> Galileo found that the period depends only on
    the length of the cord. Newton went further and measured $g$ using
    pendulums, deriving the period mathematically from his mechanics.</aside>

    Here you have what looks like MMD math inside of HTML. But that is not
    interpreted as MMD math, just as `**Galileo**` would not be bold inside
    of that `<aside>` block. (`<aside>` is a block level, not a span level,
    element.)

    If you properly indicate that you want to parse MMD inside of that HTML
    block, then the `$g$` becomes math (both in the editor pane by syntax
    highlighting, and in the preview with MathJax):

    <aside class="myaside">

    Galileo found that the period depends only on the length of the cord.
    Newton went further and measured $g$ using pendulums, deriving the
    period mathematically from his mechanics.

    </aside>

    Re: 2 different computers -- Make sure the preference settings are the
    same, particularly Preview and Advanced.

    Re: MathJax -- that link you used is deprecated. Composer uses the
    valid link:

    <script type=\"text/javascript\"
    src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-AMS-MML_HTMLorMML\"></script>

    CSS will change the appearance, but unless you do something tricky,
    won't change the content. And won't change the way that things are
    parsed. So that isn't it.

    F-

  12. 12 Posted by Raymond Brock on 29 Jun, 2018 02:41 PM

    Raymond Brock's Avatar

    hi
    I know that you’re the guy to whom we owe a debt for getting mathematics into Markdown, so I can’t quibble with your stating the rules. It really changed everything for scientists like me, and mathematicians.

    I think that in the end, I had the strict MMD rules button selected on this one computer that was much more unhappy than the other two. What I’ve done however, is the following, after fixing this… I’m now rendering in Marked2. While the mathematics is probably fixable in MC, I have many full-width figures in my chapters and the source-preview synchronization in MMC is often frustrated. I know you’ve got a clever algorithmic approach to tethering the preview to the source, but I think my use case is extreme. For some reason, Marked2 seems to handle this and I can see rendering side by side with little or no adjustment, so this works for me.

    Of course, I’m not done with questions. I like a particular dark theme TextMate setup that I use and I’ve replicated that as a theme in your setup. However, with the dark background the cursor is really hard to find. Is there any way to adjust the cursor…both in its wandering-around state with the mouse as well as the vertical line, insert-point in text?

    Thanks for sticking with me. As I presume you know, I happily purchased MC pro almost as soon as it came out and it’s my choice for long-form writing in markdown.

    Ray

    On Jun 26, 2018, at 6:50 PM, Fletcher <[email blocked]<mailto:[email blocked]>> wrote:

  13. Support Staff 13 Posted by Fletcher on 30 Jun, 2018 01:11 AM

    Fletcher's Avatar

    First -- whatever tool works best for you is what you should use.

    That said, every release of Composer has the latest version of MMD.
    Most other programs that say they use MMD are using versions of MMD that
    are years, sometimes even 5+ years, out of date. Which means they don't
    get the new features and bug fixes that I release.

    So eventually, the behavior of MMD in the other apps should fall in line
    with Composer at some point.

    There is no "strict MMD". There is "strict Markdown" and there is
    "MultiMarkdown." If you turned off MMD, then many features are
    disabled. So it's no wonder you were having trouble.... ;)

    As of when I last checked, there surprisingly did not seem to be a
    straightforward way to change the mouse pointer color. You can readily
    change the insertion point (cursor) color in themes (most of mine do),
    but not the mouse color. I'll see if Apple has improved this lately,
    but a quick Google search suggests not.

  14. 14 Posted by Raymond Brock on 30 Jun, 2018 12:26 PM

    Raymond Brock's Avatar

    Yes, “strict markdown” was selected on that one computer and yet it was respecting some…indeed, most… mathematics. So MathJax was still at work somehow.

     The mouse is quite different in MC in a dark theme than it is at least in TextMate, which I was emulating. I’ve attached a short movie that shows this.

    Ray

  15. Support Staff 15 Posted by Fletcher on 30 Jun, 2018 02:43 PM

    Fletcher's Avatar

    MathJax is separate -- it is a javascript that does its own thing,
    regardless of the underlying document. **BUT** if you disabled MMD,
    then math will not be properly processed, so the contents of the math
    section may or may not be valid. This caused the issue you had with
    line breaks not being respected, for example.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac