# Post with many lines of display math takes up most of the Questions page

Notice that a single question with many lines of display math is taking up most of the window. I actually thought I had accidentally clicked into a question.

I'm guessing that Stack-Exchange takes the first $n$ characters/words of a post and displays them, but (as you can see above), this can make for a very long display when the post contains display math. I don't imagine this is the intended behavior.

• It appears you are viewing the question body not just the title. The question hasn't been edited and since the screen shot says 5mins ago, it would show an edit history by now. here is the post. I would guess some kind of technical error, browser or site. – dustin Feb 14 '15 at 23:16
• @dustin I had thought that viewing the question body and title was the default behavior? – Strants Feb 14 '15 at 23:22
• On the front page, you should only see the title. Seeing the body of the question isn't intended behavior (unless there is a setting you can change for yourself indicating you want this to occur). – dustin Feb 14 '15 at 23:23
• @dustin This is the /questions page, which shows brief (up to 200 characters) excerpts of questions. With MathJax displays, that can be a lot of vertical space sometimes. – user147263 Feb 14 '15 at 23:24
• @FamousBlueRaincoat I thought they were viewing from the front page. – dustin Feb 14 '15 at 23:25
• @Famous Thank you, that is correct. I guess my default behavior is to go to /questions, so I just didn't think 'frontpage' could refer to something else! – Strants Feb 14 '15 at 23:26
• The confusion is from your title of the meta post. You mention front page. – dustin Feb 14 '15 at 23:27

I came up with a user script fix for this problem. Basically, what it does is turn off display math entirely in the questions list, rendering it inline instead.

For the curious, here's the code:

MathJax.Hub.Register.StartupHook( "End Config", function () {
var conf = MathJax.Hub.config.tex2jax;
conf.inlineMath = conf.inlineMath.concat( conf.displayMath );
conf.displayMath = [];
} );


It works simply by tweaking the MathJax config so that all the delimiters for display math are listed as delimiters for inline math instead.

I've added this code to the development branch of SOUP; if there are no unexpected side effects, it should be part of the next stable SOUP version, v1.30. (Impatient and/or daring folks can, of course, just install the devel version to get all the newest bugs and features.) Based on my quick testing, it seems to work as intended:

### After:

Note that this code needs to be run before or during the MathJax config phase; SOUP accomplishes this by injecting this code into the page as a MathJax config script before the page (and MathJax) loads. There have been some reports that this is not always 100% reliable on Chrome, apparently because even user scripts with @run-at document-start sometimes get loaded too late there. If you know a better way, please tell me.

Also, obviously, running this code on all pages would be counterproductive, since it would disable display math entirely on the whole site. Instead, SOUP currently runs it only on the following pages:

Those are all the places I can think of that should show questions in snippet view; if you know any other places that could use this fix, please let me know.

Update: The next (alas, long overdue) SOUP release, v1.46, has a completely rewritten fix for this issue. Instead of messing with math delimiter settings, the new fix sets up a MathJax hook that runs between the math parsing and rendering stages, and simply strips the mode=display attribute from any math elements that should be forced inline:

var displayMathScripts = 'script[type^="math/"][type$="mode=display"]'; var excludedParents = '.comment, .summary, #sidebar, #question-header'; MathJax.Hub.Register.MessageHook( "Begin Process", function (message) { var elements = message[1];$(elements).find(displayMathScripts).each( function () {
if ( $(this).closest(excludedParents).length == 0 ) return; this.type = this.type.replace(/;\s*mode=display$/, "");
} );
} );


One advantage of this method is that it applies to all types of display math syntax, including e.g. ... . (I bet most of you didn't even know that you can write \begin / \end math blocks without $$ or $ / $ like that!) The main advantage, however, is that the new fix can selectively disable display math only in some parts of a page, while leaving it enabled elsewhere on the same page. Currently, I've configured it to convert display math to inline math in comments, post summaries (basically duplicating the old functionality), question titles and anywhere in the sidebar. I think that should pretty much cover every place where you might not want display math to appear, but suggestions for improvement are welcome. (Alternatively, it might be better to make disabling display math the default, and only enable it in post text and previews. If I went that route, however, I'd need to make sure that I don't miss any odd places where display math should work, like edit histories, review or even chat.) • This is a test of display math in comments:$$1 + 1 = 2, $$2 + 2 = 4.$$ The next version of SOUP should render these inline too. – Ilmari Karonen May 17 '16 at 18:18
• Personally, I find display math in comments to be helpful (when needed), and would prefer not to have them converted to inline. The other places sound reasonable though. – mrf May 18 '16 at 6:37
• @mrf: It is, arguably, helpful, but it also kind of goes against the design intent of comments, which are supposed to be brief notes. That's why a lot of Markdown features, such as headings, bulleted lists and even paragraph breaks are disabled in comments. MathJax display math is, currently, an exception; because it's not explicitly disabled, it can be (ab)used to make comments look like full posts. Whether that's desirable or not is, however, another matter. – Ilmari Karonen May 18 '16 at 12:34
• (Still, your objection is noted, and I'll seriously reconsider including this particular feature in SOUP; it is not intended for controversial changes.) – Ilmari Karonen May 18 '16 at 12:34
• @mrf: Ps. I just posted a feature / discussion request on disabling display math in comments. – Ilmari Karonen May 18 '16 at 13:34

I think this is by design. The display of question summaries is MathJax-agnostic: the fragment shown may contain multiple display formulas, or a broken piece of a formula, whatever fits in the character limit.

As pointed out here, this often results in question lists that show unrendered or incorrectly rendered TeX. Also, as in your case, the rendered formulas can take up more vertical space than one would expect from a summary.

I include search link so that the issue described in the question can be reliably reproduced.