Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Specially in beamer presentations, I use a custom environment to change the vertical space around a formula. The code is:

\newenvironment{shrinkeq}[1]
{ \bgroup
  \addtolength\abovedisplayshortskip{#1}
  \addtolength\abovedisplayskip{#1}
  \addtolength\belowdisplayshortskip{#1}
  \addtolength\belowdisplayskip{#1}}
{\egroup}

However, an unwanted horizontal space is added in front of the text following the formula. For example, the code

Text before text before text before\dots
\[ \int_{a_1}^{b_1}f(x)dx+\int_{a_2}^{b_2}g(x)dx+\int_{a_3}^{b_3}h(x)dx=0 \]
Text after text after text after\dots
\bigskip

Text before text before text before\dots
\begin{shrinkeq}{-2ex}
\[ \int_{a_1}^{b_1}f(x)dx+\int_{a_2}^{b_2}g(x)dx+\int_{a_3}^{b_3}h(x)dx=0 \]
\end{shrinkeq}
Text after text after text after\dots

produces

alt text

The issue can be fixed by putting a \null after \end{shrinkeq} but I do not understand why this works.

¿Is there a better way to do this?

share|improve this question

1 Answer 1

Line breaks cause white space, like blanks do. Note the line break between \end{shrinkeq} and the following text.

A local solution would be commenting out the line break: \end{shrinkeq}%

A global solution would be adding \ignorespacesafterend to the end of your environment definition:

\newenvironment{shrinkeq}[1]
{ \bgroup
  \addtolength\abovedisplayshortskip{#1}
  \addtolength\abovedisplayskip{#1}
  \addtolength\belowdisplayshortskip{#1}
  \addtolength\belowdisplayskip{#1}}
{\egroup\ignorespacesafterend}

This definition causes that blanks and line breaks directly following the environment would be ignored.

share|improve this answer
    
Thank you Stefan! I did not know the <code>\ignorespacesafterend</code> command. –  rgallego Dec 9 '10 at 15:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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