0

This question about displaying equations on the web is similar to what I'm asking but does not answer my question. It's about math. I'm extending that to proofs.

This is a key difference because my main difficulty is formatting issues like adding newlines, and you don't need to worry about those when you're writing isolated math or equations. I'm using MathJax, but any sentences I write are all on the same line because I don't know how to use MathJax to simply insert a newline, and it's surprisingly hard to find.

Community
  • 1
  • 1
tscizzle
  • 11,191
  • 15
  • 54
  • 88
  • Your title and "how do I do a newline in mathjax" are very different questions. Why did you abandon [your previous question](http://stackoverflow.com/q/34236097/2336725)? – Teepeemm Dec 13 '15 at 20:54
  • The previous question sort of lead me to this more general question. I wanted to make sure that my previous question wasn't moot because I was already solving the more general problem foolishly. And it helped because the previous question would not have lead to the
    solution since that has nothing to do wit MathJax.
    – tscizzle Dec 13 '15 at 21:11
  • At a fundamental level, a proof needs line breaks about as often as a web page (which is rarely). If you're manually breaking lines more than that, you're doing it wrong. And "the best way" type of question is not a good fit for SO. And your answer turns out to depend on the fact that you're using Django, which your question didn't at all indicate. – Teepeemm Dec 14 '15 at 21:52
  • Point taken on the "the best way" style question and the Django part. As for the not needing to manually break lines often, a proof could have prose instead of equations in a lot of spots and in prose making a new line or paragraph is very common. Also if I were hard-coding the proof on a page then sure, HTML is obviously the right place for the linebreak logic, but I have a spot in the page for the proof and then the proof is passed in as a variable, so it was a little trickier. Regardless, I agree this question could be closed, but I didn't realize the flaws until later and I can't delete. – tscizzle Dec 14 '15 at 22:04

3 Answers3

2

When I type "MathJax newline" into Google the first link is interesting but the third one seems to answer it, too. Just use \\ like you would in Latex.

Community
  • 1
  • 1
deamentiaemundi
  • 5,502
  • 2
  • 12
  • 20
  • [My previous question](http://stackoverflow.com/questions/34236097/mathjax-newline-not-rendering-simply-shows-the). For some reason, that doesn't work :( – tscizzle Dec 12 '15 at 20:48
  • Ok, so the problem is that my entire proof isn't wrapped in `$$ ... $$`. So putting \\ doesn't do anything, and putting `
    ` shows up as
    probably for some reason about escaping HTML, which I shouldn't conflate with this question. I can just put `$$$$` and it breaks the line (by adding a blank equation) which I don't love because it always puts 2 newlines, but it does break the line.
    – tscizzle Dec 12 '15 at 20:52
  • @tscizzle typing `foo\\bar` in a `$$` block in an answer over on `math.stackexchange` produces a new line. Why isn't your proof wrapped in `$$`? – Paul S. Dec 12 '15 at 20:52
  • Our comments were very near, so you probably didn't see, but the problem is that one doesn't want to put an entire proof in `$$ ... $$`, so putting those in only where I want them means I can only do. at fewest, 2 newlines. – tscizzle Dec 12 '15 at 20:54
  • @tscizzle I think you're going to need to make an _"example proof"_ for us as a testcase using _jsfiddle/jsbin/etc_ if you want more meaningful answers. – Paul S. Dec 12 '15 at 20:58
  • Thanks for the help. The play is to use HTML `
    ` and the problem was autoescaping HTML. Turning off the autoescape (I happened to be in Django, so that's just `{% autoescape off %}{% some_proof %}{% endautoescape %}` in the HTML file) and using `
    ` works exactly as I want and I think is what MathJax expects users to do.
    – tscizzle Dec 12 '15 at 21:08
1

The play is to use HTML <br>, and the problem I had before doing that was autoescaping HTML. Turning off the autoescape (I happened to be in Django, so that's just {% autoescape off %}{% some_proof %}{% endautoescape %} in the HTML file) and using <br> works exactly as I want and I think is what MathJax expects users to do. So you can write math with MathJax and format the proof with HTML.

tscizzle
  • 11,191
  • 15
  • 54
  • 88
0

I don´t know if it's your case but if you are developing an web form/application, to show mathematic symbols you should use a symbol font that can be interpretated by the browser.

In other words, use a symbol font and display the wanted mathematic symbol using its ASCII code.

Take a look at these websites, they may help you out. http://www.math.vanderbilt.edu/ourequip/webstuff/postmath.html

http://symbolcodes.tlt.psu.edu/bylanguage/math.html

duffymo
  • 305,152
  • 44
  • 369
  • 561
Daniel
  • 273
  • 4
  • 18