I want to define a new environment ends with a $\omega$ in newline. But environment like displaymath already start a newline after itself, so I do not start a newline in this case. That is, start a newline only after normal text but not environment. How to make it?

The original definition is as following which starts a newline after environment also.

\vskip\medskipamount % or other desired dimension
\leaders\vrule width \textwidth\vskip0.4pt % or other desired thickness
\vskip\medskipamount % ditto
}{\mbox{}~\newline\mbox{} \hfill$\Omega$\newline}

As suggested by Peter Grill, I define a \smartsmallskip. And as suggested by David, I change the \newline to \par.

  \ifdim\lastskip>0pt \else \smallskip\fi

\vskip\medskipamount % or other desired dimension
\leaders\vrule width \textwidth\vskip0.4pt % or other desired thickness
\vskip\medskipamount % ditto

Is there still some question I should take care of?

  • 1
  • @PeterGrill Thanks! it does. Should I delete this post? – Eden Harder Feb 26 '14 at 2:02
  • 1
    why \newline and the blank lines from\mbox{}~ rather than \par and vertical space? or better a definition using \newtheorem or similar? This version will have very strange behaviour near a page break. – David Carlisle Feb 26 '14 at 2:02
  • 1
    it's better to use a list environment (as used by \newtheorem) as that takes care of things, as is, there is not control over the space before Note the page could break after the heading before the environment contents (or after the leaders) and the spacing between the rule and first line of text is going to be rather variable due to the \nointerlineskip (which means it will be different whether or not there is a capital letter or accent on the first line of content) the final \newline should be a \par (most likely). – David Carlisle Feb 26 '14 at 2:32
  • 1
    @EdenHarder Don't forget that in LaTeX there is \addvspace, so \addvspace{\smallskipamount} is what you need instead of \smartsmallskip – egreg Feb 26 '14 at 7:54

This should do what you want; instead of a \smallskip before the last line, I have used a strut next to the Omega (actually, I think there shouldn't be an additional space and the symbol should go at the end of the last line). The line shouldn't be detached from the heading and the body thanks to \nopagebreak, the same for the last line.


   \hspace*{\fill}\mbox{\ifdim\skip0>0pt \else\rule{0pt}{2ex}\fi$\Omega$}\par





enter image description here

| improve this answer | |
  • Could you explain about \mbox{\ifdim\skip0>0pt \else\rule{0pt}{2ex}? Thanks a lot! – Eden Harder Feb 26 '14 at 12:22
  • @EdenHarder That's for adding the strut only if the previous material doesn't end with a skip (such as after a math display). – egreg Feb 26 '14 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.