Hello, Suppose I have the following code: blah blah blah blah blah blah blah blah blah \startmpformula formula \stopmpformula and that it yields the following output blah blah blah blah blah blah blah blah blah formula that is, the final "blah" is placed so far to the left of "formula" that it would be desireable to reduce the vertical space between the text and the formula such that we get the following output instead: blah blah blah blah blah blah blah blah blah formula The question is now: How do I do that? Regards, -- Emil Hedevang Lohse http://home.imf.au.dk/emil/ Alle spørgsmål er lige dumme. Og spørgsmålet "Kan ænder flyve?" er ikke dumt.
Tuesday, September 16, 2003 Emil Hedevang Lohse wrote:
Hello,
Suppose I have the following code:
blah blah blah blah blah blah blah blah blah
\startmpformula formula \stopmpformula
and that it yields the following output
blah blah blah blah blah blah blah blah blah
formula
that is, the final "blah" is placed so far to the left of "formula" that it would be desireable to reduce the vertical space between the text and the formula such that we get the following output instead:
blah blah blah blah blah blah blah blah blah formula
The question is now: How do I do that?
You don't :\ Sadly, Hans decided that the difference between abovedisplayskip and abovedisplayshortskip was unnecessary. Hans? -- Giuseppe "Oblomov" Bilotta
At 17:59 17/09/2003 +0200, you wrote:
You don't :\ Sadly, Hans decided that the difference between abovedisplayskip and abovedisplayshortskip was unnecessary. Hans?
that's not true -) the problem is that it is quite hard to get the spacing ok in situations like text formula text this has to do with the fact (and i spent days on that topic) that tex only knows the length of the last line when in display math mode and even then not always this means that when one wants control over spacing, and to take the length of the last lin einto account, one has to go through a lot of trouble; i once had it working but somehow lost something in the code, so i need to look at it suggestion for gbetex: lastlinelength always available Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
At 22:32 16/09/2003 +0200, you wrote:
The question is now: How do I do that?
i'll have a look at it, one complication is that the last line width is not available outside math mode (which is a pain) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Hi
one complication is that the last line width is not available outside math mode (which is a pain)
If really needed one can use quite old plain macro which try to soften this pain... However for short paragraphs it needs some changes (\prevgraf can't be less then zero). Meybe this is not very nice but... \newif\ifmeasdisp \measdispfalse \newcount\lineno \newdimen\linesize \def\measline{\ifhmode \bgroup \parfillskip=0pt plus 1fil \predisplaypenalty=10000 \postdisplaypenalty=10000 \displaywidowpenalty=\widowpenalty \abovedisplayskip=-\baselineskip \belowdisplayskip=-\baselineskip \abovedisplayshortskip=-\baselineskip \belowdisplayshortskip=-\baselineskip $$\global\linesize=\predisplaysize$$ \global\advance\linesize by -2em \global\lineno=\prevgraf \global\advance\lineno by -3 \ifmeasdisp\immediate\write16{>>\the\lineno: \the\linesize}\fi \global\advance\lineno by -1 \global\prevgraf=\lineno \kern\linesize \egroup \else \immediate\write16{! I'M IN VMODE---MEASURING IGNORED}% \fi} % ------------------------------------------------------------------------ % Author: B. Jackowski, 22 V 1990. % ------------------------------------------------------------------------ Regards
At 19:24 17/09/2003 +0200, you wrote:
Hi
one complication is that the last line width is not available outside math mode (which is a pain)
If really needed one can use quite old plain macro which try to soften this pain... However for short paragraphs it needs some changes (\prevgraf can't be less then zero). Meybe this is not very nice but...
\newif\ifmeasdisp \measdispfalse \newcount\lineno \newdimen\linesize \def\measline{\ifhmode \bgroup \parfillskip=0pt plus 1fil \predisplaypenalty=10000 \postdisplaypenalty=10000 \displaywidowpenalty=\widowpenalty \abovedisplayskip=-\baselineskip \belowdisplayskip=-\baselineskip \abovedisplayshortskip=-\baselineskip \belowdisplayshortskip=-\baselineskip $$\global\linesize=\predisplaysize$$ \global\advance\linesize by -2em \global\lineno=\prevgraf \global\advance\lineno by -3 \ifmeasdisp\immediate\write16{>>\the\lineno: \the\linesize}\fi \global\advance\lineno by -1 \global\prevgraf=\lineno \kern\linesize \egroup \else \immediate\write16{! I'M IN VMODE---MEASURING IGNORED}% \fi} % ------------------------------------------------------------------------ % Author: B. Jackowski, 22 V 1990. % ------------------------------------------------------------------------
this 'using a fake formula' is more or less the way i determine the last line length, but keep in mind that this only works in situations like: some text \measline and not in some text \par (or empty line) \measline Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Thursday, September 18, 2003 Hans Hagen wrote:
this 'using a fake formula' is more or less the way i determine the last line length, but keep in mind that this only works in situations like:
some text \measline
and not in
some text \par (or empty line) \measline
Hans, that is *not* supposed to work in those cases because a \par or an empty line determine an end-of-paragraph, so the formula starts a new paragraph and the lenght of the previous line is *irrelevant* --you don't have a mid-paragraph display. I know that you like those freeform spacey sources, but they are not really 100% compatible with the empty line => paragraph concept of TeX :) -- Giuseppe "Oblomov" Bilotta
At 10:47 18/09/2003 +0200, you wrote:
Thursday, September 18, 2003 Hans Hagen wrote:
this 'using a fake formula' is more or less the way i determine the last line length, but keep in mind that this only works in situations like:
some text \measline
and not in
some text \par (or empty line) \measline
Hans, that is *not* supposed to work in those cases because a \par or an empty line determine an end-of-paragraph, so the formula starts a new paragraph and the lenght of the previous line is *irrelevant* --you don't have a mid-paragraph display.
I know that you like those freeform spacey sources, but they are not really 100% compatible with the empty line => paragraph concept of TeX :)
well, the problem is that in both cases: text $$math$$ text text \par $$math$$ \par text one wants to optimize spacing, so the limitation of not having access to the last line length is a pitty (i understand that it can be tricky in cases like: text \par somevboxmanipulation $$math$$ since then one may wonder what the last line length applies to Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Hans, that is *not* supposed to work in those cases because a \par or an empty line determine an end-of-paragraph, so the formula starts a new paragraph and the lenght of the previous line is *irrelevant* --you don't have a mid-paragraph display.
I know that you like those freeform spacey sources, but they are not really 100% compatible with the empty line => paragraph concept of TeX :)
Thursday, September 18, 2003 Hans Hagen wrote:
well, the problem is that in both cases:
text $$math$$ text
text \par $$math$$ \par text
one wants to optimize spacing, so the limitation of not having access to the last line length is a pitty (i understand that it can be tricky in cases like:
text \par somevboxmanipulation $$math$$
since then one may wonder what the last line length applies to
The point is that it's not true that in both cases one wants to optimize spacing because the two cases have a totally different meaning: in the first case you have a displayed equation within a paragraph, so it makes sense to "optimize spacing" to put the text and the formula as close together as possible (within aesthetical limits). In the second case you have a formula which is on a paragraph of its own, and is therefore "absolute" from the surrounding text. In this case you *don't* want to put the formula and text as close together as possible because they are (supposedly) logically *independent* concepts and having them more spaced in the printout helps noticing this difference. In the end it always end up on the totally different views on displayed material that you and TeX have. We discussed this for the "autoindent" stuff, remember? You always consider displays a "separate entity" from the surrounding text, whereas TeX allows it to be separate or not (depending on \pars around it). TeX approach is both more flexible and more "correct". Let's say for example that we're discussing Einstein's equation. The following three examples have different logical meaning and should therefore be formatted appropriately differently: === EXAMPLE 1: Display part of the paragraph === Einstein's equation $$E=mc^2$$ ties energy and mass of a body to etc === EXAMPLE 2: Display part of the previous paragraph but not of the following one === A relation between mass and energy of a body is expressed by Einstein's equation $$E=mc^2.$$ We shall see further on that etc === EXAMPLE 3: Display part of the following paragraph but not of the previous one === some text etc. $$E=mc^2$$ is Einstein equation and it ties energy and mass of a body etc. ================================================ In Ex1, you want the displayed equation to have as little spacing as possible both above and below, and the following text should NOT start with an indent. In Ex2, you want the displayed equation to be as close as possible to the previous text, and to have some spacing below, to ensure that it's clearly distinguishable from the next paragraph, which is a new entity. Also, the following text should start with an indent. In Ex3, you want there to be more space above than below because the previous text is independent from the equation. On the contrary, it should be close together with the following text which is in the same paragraph as the equation. The following text should NOT be indented. Now, while we solved the indenting issue with the introduction of the indentnext=auto key=value, which automatically takes care of the various cases, you now have to convince yourself that the same must hold true for spacing around displayed material: text $$math$$ text and text\par $$math$$\par text are NOT the same thing and should be treated differently! -- Giuseppe "Oblomov" Bilotta
At 14:05 18/09/2003 +0200, you wrote:
In the end it always end up on the totally different views on displayed material that you and TeX have. We discussed this for the "autoindent" stuff, remember? You always consider displays a "separate entity" from the surrounding text, whereas TeX allows it to be separate or not (depending on \pars around it). TeX approach is both more flexible and more "correct".
hm, in this case i more tend to look at the grayness of a page and then decide on a space correction like this; (which is why i also have a threshold)
Let's say for example that we're discussing Einstein's equation. The following three examples have different logical meaning and should therefore be formatted appropriately differently:
=== EXAMPLE 1: Display part of the paragraph ===
Einstein's equation $$E=mc^2$$ ties energy and mass of a body to etc
=== EXAMPLE 2: Display part of the previous paragraph but not of the following one ===
A relation between mass and energy of a body is expressed by Einstein's equation $$E=mc^2.$$
We shall see further on that etc
=== EXAMPLE 3: Display part of the following paragraph but not of the previous one ===
some text etc.
$$E=mc^2$$ is Einstein equation and it ties energy and mass of a body etc.
================================================
In Ex1, you want the displayed equation to have as little spacing as possible both above and below, and the following text should NOT start with an indent.
In Ex2, you want the displayed equation to be as close as possible to the previous text, and to have some spacing below, to ensure that it's clearly distinguishable from the next paragraph, which is a new entity. Also, the following text should start with an indent.
yes, but a very short last line will make uit look quite ugly, i.e. there is already quite some space there; i'd rather tend to have a different threshold then (say 4em instead of 2em, which boils down to: some long text formula part of paragraph some text formula part of paragraph some long text formula not part of paragraph some text formula not part of paragraph so, to let the horizontal distance between end of line text and begin of text also play a role. text $$math$$ text
and
text\par $$math$$\par text
are NOT the same thing and should be treated differently!
i know, but that's on the agenda; and even then, i'll add options to control the look and feel -) (in practice i think that it also depends on the taste and specific formula, say x=2 vs x=sqrt(2) may demand their own spacing rules) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Thursday, September 18, 2003 Hans Hagen wrote:
yes, but a very short last line will make uit look quite ugly, i.e. there is already quite some space there; i'd rather tend to have a different threshold then (say 4em instead of 2em, which boils down to:
some long text formula part of paragraph
some text formula part of paragraph
some long text
formula not part of paragraph
some text formula not part of paragraph
so, to let the horizontal distance between end of line text and begin of text also play a role.
actually a very short last time should NOT happen full stop. :) There was a discussion on this recently on c.t.t., about "French" orphans or "Russian" paragraphs. You can look them up with GoogleGroups. To prevent those lines, Donald Arseneau proposes something like \parfillskip = .5\hsize plus .092\hsize minus .5\hsize He says: "This not only prohibits the short final lines, but heavily penalizes moderately short final lines. Another bad feature is that \abovedisplayshortskip will never be used, leading to excessive white space around some formulas." Given that you never use \abovedisplayshortskip, we're safe ;)
text $$math$$ text
and
text\par $$math$$\par text
are NOT the same thing and should be treated differently!
i know, but that's on the agenda; and even then, i'll add options to control the look and feel -)
(in practice i think that it also depends on the taste and specific formula, say x=2 vs x=sqrt(2) may demand their own spacing rules)
Don't exaggerate. The human eye is slack enough to give those spacing some tolerance :) -- Giuseppe "Oblomov" Bilotta
At 17:31 18/09/2003 +0200, Giuseppe Bilotta wrote:
proposes something like
\parfillskip = .5\hsize plus .092\hsize minus .5\hsize
hm, we need a way to parametrize this, will think of it
Another bad feature is that \abovedisplayshortskip will never be used, leading to excessive white space around some formulas."
these skips around math are tricky anyway; also, i noticed that occasionally some baselineskip is added; another painful thing is the automatic 2em displayindent
Don't exaggerate. The human eye is slack enough to give those spacing some tolerance :)
i noticed that in many tex docs on the web -) also, i am quite sensitive to it, so, sorry to all those users who suffer from the side effects in context Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Thursday, September 18, 2003 Hans Hagen wrote:
At 17:31 18/09/2003 +0200, Giuseppe Bilotta wrote:
proposes something like
\parfillskip = .5\hsize plus .092\hsize minus .5\hsize
hm, we need a way to parametrize this, will think of it
I was hoping you would :)
Another bad feature is that \abovedisplayshortskip will never be used, leading to excessive white space around some formulas."
these skips around math are tricky anyway; also, i noticed that occasionally some baselineskip is added; another painful thing is the automatic 2em displayindent
Don't exaggerate. The human eye is slack enough to give those spacing some tolerance :)
i noticed that in many tex docs on the web -) also, i am quite sensitive to it, so, sorry to all those users who suffer from the side effects in context
Make it an option, so that both you and "those who suffer" can be happy about it :) -- Giuseppe "Oblomov" Bilotta
Hi, I fixed/extended some experimental code. See attached file. Of course you need to move the core file to base and regenerate the format. If you want autospacing, you need the \epar (this will trigger some line width calculations, somethign that needs to take place inside a par). You can also \moveformula ([-top] but that is the default and onlyh option in not grid mode) \optimizedisplayspacingtrue % needed test \par \dorecurse{10}{test } \moveformula \startformula test \stopformula test \endgraf test test \par \dorecurse{10}{test } \startformula test \stopformula test \endgraf test \dorecurse{30}{\bpar \dorecurse\recurselevel{test } \epar \startformula formula \stopformula} no guarantees -) Hans ------------------------------------------------------------------------- Hans Hagen | PRAGMA ADE | pragma@wxs.nl Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: +31 (0)38 477 53 69 | fax: +31 (0)38 477 53 74 | www.pragma-ade.com ------------------------------------------------------------------------- information: http://www.pragma-ade.com/roadmap.pdf documentation: http://www.pragma-ade.com/showcase.pdf -------------------------------------------------------------------------
Hans Hagen
Hi,
I fixed/extended some experimental code. See attached file. Of course you need to move the core file to base and regenerate the format.
If you want autospacing, you need the \epar (this will trigger some line width calculations, somethign that needs to take place inside a par).
You can also \moveformula ([-top] but that is the default and onlyh option in not grid mode)
\optimizedisplayspacingtrue % needed
test \par \dorecurse{10}{test } \moveformula \startformula test \stopformula test \endgraf test test \par \dorecurse{10}{test } \startformula test \stopformula test \endgraf test
\dorecurse{30}{\bpar \dorecurse\recurselevel{test } \epar \startformula formula \stopformula}
Thank you for the patch \moveformula now works fine. I have not tested the \bpar-\epar thing since it looks like there is a small bug: when I typeset your file test.tex, the ninth formula on page 2 is incorrectly move up. Regards, -- Emil Hedevang Lohse http://home.imf.au.dk/emil/ Alle spørgsmål er lige dumme. Og spørgsmålet "Kan ænder flyve?" er ikke dumt.
participants (4)
-
Emil Hedevang Lohse
-
Giuseppe Bilotta
-
Hans Hagen
-
Pawel Jackowski na Onet