2

I want to insert formula in text and I used equation as shown:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

So, $\rho : G \rightarrow GL(n,\mathbb{F})$ is representation if and only if

\begin{equation*}
\forall g,h \in G) \hspace{2mm} \rho(gh)=\rho(g)\rho(h).
\end{equation*} 

\end{document}

My problem is too big vertical spacing before and after formula.

6
  • 3
    remove the blank line between the text and the equation. that will always leave too much space. Commented May 27, 2014 at 13:44
  • 1
    By the way, I would use \colon instead of :; \to instead of \rightarrow; \quad instead of \hspace{2mm}.
    – Manuel
    Commented May 27, 2014 at 13:47
  • Why is \colon preferable to :? Commented May 27, 2014 at 15:31
  • You can also modify the parameters \abovedisplayskip and \belowdisplayskip if you really want to modify the default spacing (after applying Barbara's suggestion).
    – Mafra
    Commented May 27, 2014 at 19:00
  • 1
    @AnnieCarter When you're talking about functions, you want the colon to be closer to the function name as opposed to equidistant between name and the domain–range portion. A plain : is (I believe) more useful in set comprehensions: \{ x : x = 0 \pmod 3 \}. Commented May 27, 2014 at 19:32

3 Answers 3

2

If you truly believe that the default values of the length parameters \abovedisplayskip and \belowdisplayskip make LaTeX insert a bit too much vertical whitespace above and below a displayed equation, you could reduce those values a bit. E.g.,

\addtolength\abovedisplayskip{-1ex}
\addtolength\belowdisplayskip{-1ex}

Don't go overboard, though.

Do also follow barbara beeton's advice not to leave blank lines above and below the code that defines the displayed equations. And, if your document loads the setspace package and uses a spacing setting other than \singlespacing, do load the package with the option nodisplayskipstretch. Doing so turns off line stretching before and after displays. If your document uses \doublespacing you'll notice a huge effect.

2
  • @MicoIn the preamble, I have written \addtolength\abovedisplayskip{-1ex} \addtolength\belowdisplayskip{-1ex} but no effect in the space between text and equation, and no effect between the equation and next text. I have \usepackage{setspace} What could be happening ?
    – DavidC.
    Commented Jun 24, 2014 at 20:42
  • @DavidC. - "No effect" is not a very specific diagnosis. To have a chance to find out what may be going on, please consider posting a new question with a full MWE that establishes the problem you're looking to fix. Thanks.
    – Mico
    Commented Jun 24, 2014 at 20:55
2

You can use \useshortskip from the nccmath package — but will change only \abovedisplayskip – or a centerenvironment — the difference is very small – or create a myequ environment, that adds smallskip to \baselineskip (this may be changed, of course).

Here is a code that shows these different possibilities:

\documentclass{article}
\usepackage{amsmath, amsfonts}
\usepackage{nccmath}
\usepackage{etoolbox}
\newenvironment{myequ}{%
\smallskip\par\centering$\displaystyle}
{$\smallskip\par}

\begin{document}

\noindent With the \verb+equation*+ environment : \medskip

So, $\rho : G \rightarrow GL(n,\mathbb{F})$ is representation if and only if
\begin{equation*}
\forall g,h \in G \hspace{2mm} \rho(gh)=\rho(g)\rho(h).
\end{equation*}
Text text text text text text text text text text text text text text text text text text text text. \\

\noindent With a \verb+center + environment : \medskip

So, $\rho : G \rightarrow GL(n,\mathbb{F})$ is representation if and only if
\begin{center}
$\displaystyle
 \forall g,h \in G \hspace{2mm} \rho(gh)=\rho(g)\rho(h). $
\end{center}
Text text text text text text text text text text text text text text text text text text text text. \\

\noindent With \verb+\useshortskip+ : \medskip

So, $\rho : G \rightarrow GL(n,\mathbb{F})$ is representation if and only if\useshortskip
\begin{equation*}
\forall g,h \in G \hspace{2mm} \rho(gh)=\rho(g)\rho(h).
\end{equation*}
Text text text text text text text text text text text text text text text text text text text text. \\

\noindent With the \verb+myequ+ environment : \medskip

So, $\rho : G \rightarrow GL(n,\mathbb{F})$ is representation if and only if\useshortskip
\begin{myequ}
\forall g,h \in G \hspace{2mm} \rho(gh)=\rho(g)\rho(h).
\end{myequ}
Text text text text text text text text text text text text text text text text text text text. \\

\end{document} 

enter image description here

3
  • Thanks a lot. "Myequ" solved problem completely. Thanks a lot.
    – user52529
    Commented May 28, 2014 at 9:21
  • @Bernard: In order to use the myequ environment, what package should be installed ?
    – DavidC.
    Commented Jun 24, 2014 at 20:33
  • 1
    @DavidC.: none, it uses basic LaTeX. Note that such environments cannot be referenced: they use no counter.
    – Bernard
    Commented Jun 24, 2014 at 20:55
0

In addition to Barbara's comment about removing the blank line, you can manually set line spacing using the spacing environment from the setspace package (see this link! from the LaTeX wikibook).

Working example:

\documentclass{article}
\usepackage{amsmath}
\usepackage{setspace}

\begin{document}

\begin{spacing}{0.2}
So, $\rho : G \rightarrow GL(n,\mathbb{F})$ is representation if and only if
\begin{equation*}
    \forall g,h \in G) \hspace{2mm} \rho(gh)=\rho(g)\rho(h).
\end{equation*} 
\end{spacing}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .