1

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.

  • 3
    remove the blank line between the text and the equation. that will always leave too much space. – barbara beeton May 27 '14 at 13:44
  • 1
    By the way, I would use \colon instead of :; \to instead of \rightarrow; \quad instead of \hspace{2mm}. – Manuel May 27 '14 at 13:47
  • Why is \colon preferable to :? – Annie Carter May 27 '14 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 May 27 '14 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 \}. – Sean Allred May 27 '14 at 19:32
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.

  • @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. Jun 24 '14 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 Jun 24 '14 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

  • Thanks a lot. "Myequ" solved problem completely. Thanks a lot. – user52529 May 28 '14 at 9:21
  • @Bernard: In order to use the myequ environment, what package should be installed ? – DavidC. Jun 24 '14 at 20:33
  • @DavidC.: none, it uses basic LaTeX. Note that such environments cannot be referenced: they use no counter. – Bernard Jun 24 '14 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}

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.