last day (15 days later) » 

22:34
0
Q: How to fix inline math spacings as in a normal math display?

ChamI would like to fix the horizontal math spacings, when any math expression is shown inside a block of text, without acting on the text itself. The maths spacings should be exactly the same as in a normal displayed equation (when it is shown between paragraphs). See for example the following MWE...

Are you sure there is an issue to fix? while I'm sure the referenced answer is excellent I'd never use it. The spacing in displayed math is the same as inline math (including the stretch components) it is just that things are more likely to stretch inline as part of line breaking, basically display math is like inline math in a center where the stretch glue at the sides similarly makes it less likely the finite stretch around operators is used.
Also shouldn't you also fix the inter-word space to a fixed amount? It seems very strange to allow inter-word white space to stretch but not allow the white space in mathematics on the same line.
@DavidCarlisle, I'm having the same issue (apparently) as the other guy for which you gave an answer. I'm using the microtype package, and all of the text spacings are (mostly) very beautiful. However, I hate it when LaTeX stretches or compresses my math expressions ; they look awful.
@DavidCarlisle, sorry, just forget the compilation issue: apparently, copying/pasting the code from my Web browser into my LaTeX editor creates an issue!
I really can't see how this can ever improve the spacing. (not that inline math will look usable with \displaystyle forced)
@DavidCarlisle, I use displaystyle for inline equations because I want all the indices and exponents to stay the same as in the bigger equations shown between text paragraphs. I also want the horizontal spacing to be the same. I'm only typing small math expressions inline. Never "big" expressions.
with \displaystyle you are very limited in what you can do without disturbing line spacing (your example here gets lucky) if you really get lucky in all cases then OK. For horizontal spacing I think this is based on a misunderstanding: the same horizontal space is used in display and inline math.
22:34
@DavidCarlisle, ok. But I don't want the text to have any effect on the inline math spacings. I need them to stay the same as if they were displayed between the text paragraphs. The text spacings should be variable in the normal way, but the inline math spacings should stay the same as if they were displayed under the text.
but the displayed equations with \[ \] or align etc use the same stretchy math space as the inline math (with stretch in both cases) the answer of mine that you reference, and egreg's here change both inline and display so they stay the same as each other.
I don't understand greg's answer yet. All I need, is the fix my small inline math expressions as they would appear in a full display (between paragraphs). If I use the normal way with variable inline spacings, and variable position of indices and exponents, the math expressions are frequently very ugly.
@Cham egreg's answer is simply a duplicate of the answer I gave that you reference. But I say again the default is that the same horizontal space is used in inline math and in displays. Both my answer and egreg's re-statement of it change both.
For any inline expression, I only type small things (which may have indices and exponents, and small fractions, small relations). All bigger equations are displayed below the text. When I use the normal way, the math horizontal spacings are modified by the text. I need to prevent that to happen.
I know that is what you said and that is what the answer that you linked to does. your question is a duplicate of that and egreg gives the same answer. It is your document and of course you can have any spacing that you want but you can't really call this a "fix" your choice here is different to the choice of almost every math document ever printed. It is a personal choice not in any sense a "fix".
22:48
By "fixing", I mean to "keep constant". Or if you prefer, to display as in a full math display (below text). Using local ${...}$ fixes my issue, or more specifically $\displaystyle{...}$. I just want to do the same in a global way, in the preamble (in case I change my idea), not in a local way. So what should be a proper preamble command to do the same effect as $\displaystyle{...}$ ? Using only \everymath{\displaystyle} doesn't give the same effect (the spacings aren't the same).
Actually, this is my issue: using \everymath{\displaystyle} in the preamble doesn't give the exact same output as $\displaystyle{...}$ for all inline math expressions.
@Cham but as I have said multiple times the math display do not use fixed spaces they use the same stretch space as inline math.
Ok. But my question is then the same as my previous comment.
Again, I just want a global preamble command (or set of commands) to do the same output as using $\displaystyle{...}$ in all local inline equation.
@Cham setting them in the preamble makes them all use fixed amounts but in practice this won't change many displays as they have infinite stretch at the side so the finite stretch won't be used. You will see the same if you use \raggedright for text because there is infinite stretch available the inline math 9and word spaces) would be a fixed space inmost cases.
@Cham do you have any real example where the code you put in the question does not do that? If not, what is your question?
Do you want really the same as $\displaystyle{...}$ (ie prevent line breaking as well?)
I do't understand. Sorry, there may be a communication issue. Currently, I could get the right output if I simply use $\displaystyle{...code in there...}$ for all inline maths. I want to achieve the same by a global preamble command.
Yes.
what I meant is do you ever get the wrong output if you use the muskip=1muskip lines that you have in the question? If that doesn't give you the wrong output, I do not see what your question is.
22:57
Your solution may be the right one I'm looking for. But I was wondering if it was the only one. Especially since I also need to use the \everymath{\displaystyle} command.
Should I put your commands inside the \everymath{\displaystyle} ?
@Cham you could, although it would make your displays inconsistent so I wouldn't. (doing it that way would change the spacing in align or gather but not equation
Ahaa ! This is important : does your solution also change the display of any other maths, under the text?
If so, then I would have to use braces (i.e ${...}$) for all my inline math instead?
@Cham as i have said multiple times it removes the stretch everywhere but the stretch doesn't get used much in displays hence your mistaken description of saying that you want the same spacing in inline as display. the spacing in ${....}$ is only the same as that in displays to the extent that the stretch glue is not often stretched in displays.
Geez this is complicated! For example, I write (inside text) $y_2(x) = a x^2$. The output is frequently variable, depending of the text around it. The spacings may be too strong (dilated, or compressed), because of the text itself. I don't want the text to have an effect here, so I could use ${y_2(x) = a x^2}$, which fixes the spacing.
But I also need to use $\displaystyle{y_2(x) = a x^2}$ to get proper vertical position of all indices and exponents. I simply need to do all these at the preamble level.
well do as you put in the question (but please avoid words like "proper" when you mean your non standard choice. The normal behaviour is not improper
23:08
? You mean \everymath{\displaystyle}, plus your solution? There is no other way?
@Cham why do you want two ways?
Two ways?
@Cham you have one way already and you are asking for another.
Like I said, I don't like the variable output of $y_2(x) = a x^2$, which changes depending of the text around it. I want that equation $y_2(x) = a x^2$ to have the same output whatever the text around it.
I mean the same indices and exponents as in a normal display, and the same spacings...
In other word: I don't want $y_2(x) = a x^2$ to be affected by the text flowing around it.
@Cham this is going in circles. I know that is what you want but that is what the code in your question does. and for the 1000th time the spacing in displays is the same variable space as inline, it just does not often need to stretch.
@Cham I know!!!!!!!!!!!!!!!!!! that is what the code you posted does, so what is your question?
23:12
I understand, but at least the normal display isn't affected by the text, while it is for the inline equations.
Sorry, I have to go now. Thanks for the help. But I'm still not convinced that I have the proper solution.
@Cham only because it has infinite glue to center it, if you used \begin{center} then you would similarly see that the spacing in inline math did not often need to stretch or shrink

last day (15 days later) »