TransWikia.com

fleqn and vertical space

TeX - LaTeX Asked on January 10, 2021

I’m writing my master thesis according to this template:

https://fenix.tecnico.ulisboa.pt/downloadFile/1407993358863322/Thesis_template_LaTeX_v7.zip

I’ve tried using the fleqn option right at the beginning of the Thesis.tex file, but I get huge amounts of vertical space around equations. I looked up some of the possible problems, but in the end I really can’t understand what’s causing this.

Can someone help?

Thanks!

% ----------------------------------------------------------------------
%  Set the document class
% ----------------------------------------------------------------------
documentclass[10pt,a4paper,twoside,fleqn]{report}

usepackage[utf8]{inputenc}   % <<<<< Linux
usepackage[english]{babel} % <<<<< English

renewcommand{rmdefault}{phv}
renewcommand{sfdefault}{phv}

defFontLn{% 16 pt normal
    usefont{T1}{phv}{m}{n}fontsize{16pt}{16pt}selectfont}
defFontLb{% 16 pt bold
    usefont{T1}{phv}{b}{n}fontsize{16pt}{16pt}selectfont}
defFontMn{% 14 pt normal
    usefont{T1}{phv}{m}{n}fontsize{14pt}{14pt}selectfont}
defFontMb{% 14 pt bold
    usefont{T1}{phv}{b}{n}fontsize{14pt}{14pt}selectfont}
defFontSn{% 12 pt normal
    usefont{T1}{phv}{m}{n}fontsize{12pt}{12pt}selectfont}


usepackage{geometry}   
geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}

usepackage{setspace}
renewcommand{baselinestretch}{1.5}
usepackage{graphicx}
usepackage{amsmath}  % AMS mathematical facilities for LaTeX.
usepackage{amsthm}   % Typesetting theorems (AMS style).
usepackage{amsfonts} % 
usepackage{subfigure}
usepackage{subfigmat}
usepackage{dcolumn}
newcolumntype{d}{D{.}{.}{-1}} % column aligned by the point separator '.'
newcolumntype{e}{D{E}{E}{-1}} % column aligned by the exponent 'E'
usepackage{nomencl}
makenomenclature
%
% Group variables according to their symbol type
%
RequirePackage{ifthen} 
ifthenelse{equal{languagename}{english}}%
{ % English
    renewcommand{nomgroup}[1]{%
        ifthenelse{equal{#1}{R}}{%
            item[textbf{Roman symbols}]}{%
            ifthenelse{equal{#1}{G}}{%
                item[textbf{Greek symbols}]}{%
                ifthenelse{equal{#1}{S}}{%
                    item[textbf{Subscripts}]}{%
                    ifthenelse{equal{#1}{T}}{%
                        item[textbf{Superscripts}]}{}}}}}%
}{% Portuguese
    renewcommand{nomgroup}[1]{%
        ifthenelse{equal{#1}{R}}{%
            item[textbf{Simbolos romanos}]}{%
            ifthenelse{equal{#1}{G}}{%
                item[textbf{Simbolos gregos}]}{%
                ifthenelse{equal{#1}{S}}{%
                    item[textbf{Subscritos}]}{%
                    ifthenelse{equal{#1}{T}}{%
                        item[textbf{Sobrescritos}]}{}}}}}%
}%

usepackage[number=none]{glossary}
setglossary{gloskip={}}
makeglossary
usepackage{rotating}
usepackage[pdftex]{hyperref} % enhance documents that are to be
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Begin Document                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
begin{document}

% Set plain page style (no headers, footer with centered page number)
pagestyle{plain}

% Set roman numbering (i,ii,...) before the start of chapters
pagenumbering{roman}

% -----------------------------------------------------------------------------
subsection{Equations}
label{subsection:equations}

Equations can be inserted in different ways.

The simplest way is in a separate line like this

begin{equation}
frac{{rm d} q_{ijk}}{{rm d} t} + {cal R}_{ijk}({bf q}) = 0 ,.
label{eq:ode}
end{equation}

If the equation is to be embedded in the text. One can do it like this ${partial {cal R}}/{partial {bf q}}=0$.

It may also be split in different lines like this

begin{eqnarray}
{rm Minimize}   && Y({bf alpha},{bf q}({bf alpha}))            nonumber           
{rm w.r.t.}     && {bf alpha} ,,                                 label{eq:minimize} 
{rm subject~to} && {cal R}({bf alpha},{bf q}({bf alpha})) = 0 nonumber           
&&       C ({bf alpha},{bf q}({bf alpha})) = 0 ,. nonumber
end{eqnarray}

It is also possible to use subequations. Equations~ref{eq:continuity}, ref{eq:momentum} and ref{eq:energy} form the Naver--Stokes equations~ref{eq:NavierStokes}.

begin{subequations}
    begin{equation}
    frac{partial rho}{partial t} + frac{partial}{partial x_j}left( rho u_j right) = 0 ,,
    label{eq:continuity}
    end{equation}
    begin{equation}
    frac{partial}{partial t}left( rho u_i right) + frac{partial}{partial x_j} left( rho u_i u_j + p delta_{ij} - tau_{ji} right) = 0, quad i=1,2,3 ,,
    label{eq:momentum}
    end{equation}
    begin{equation}
    frac{partial}{partial t}left( rho E right) + frac{partial}{partial x_j} left( rho E u_j + p u_j - u_i tau_{ij} + q_j right) = 0 ,.
    label{eq:energy}
    end{equation}
    label{eq:NavierStokes}%
end{subequations}

% ----------------------------------------------------------------------
end{document}
% ----------------------------------------------------------------------

One Answer

You have

> 10.0pt plus 2.0pt minus 5.0pt.
l.82 showtheabovedisplayskip
                              
? 
> 0.0pt plus 3.0pt.
l.83 showtheabovedisplayshortskip

so as it's never possible to use the short skips with fleqn there will be 10pt extra above equation, however the spacing is wrong anyway as there should never be a blank line before a display math, as it always generates a spurious white empty line of a paragraph before the equation. Similarly don't use one equation after another, use a multi-line display such as gather

output with and without fleqn

enter image description here

enter image description here

documentclass[10pt,a4paper,twoside,
%fleqn
]{report}

% not required in recent latex usepackage[utf8]{inputenc}   % <<<<< Linux
usepackage[english]{babel} % <<<<< English

renewcommand{rmdefault}{phv}
renewcommand{sfdefault}{phv}

defFontLn{% 16 pt normal
    usefont{T1}{phv}{m}{n}fontsize{16pt}{16pt}selectfont}
defFontLb{% 16 pt bold
    usefont{T1}{phv}{b}{n}fontsize{16pt}{16pt}selectfont}
defFontMn{% 14 pt normal
    usefont{T1}{phv}{m}{n}fontsize{14pt}{14pt}selectfont}
defFontMb{% 14 pt bold
    usefont{T1}{phv}{b}{n}fontsize{14pt}{14pt}selectfont}
defFontSn{% 12 pt normal
    usefont{T1}{phv}{m}{n}fontsize{12pt}{12pt}selectfont}


usepackage{geometry}   
geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}

usepackage{setspace}
renewcommand{baselinestretch}{1.5}
usepackage{graphicx}
usepackage{amsmath}  % AMS mathematical facilities for LaTeX.
usepackage{amsthm}   % Typesetting theorems (AMS style).
usepackage{amsfonts} % 
usepackage{subfigure}
usepackage{subfigmat}
usepackage{dcolumn}
newcolumntype{d}{D{.}{.}{-1}} % column aligned by the point separator '.'
newcolumntype{e}{D{E}{E}{-1}} % column aligned by the exponent 'E'
usepackage{nomencl}
makenomenclature
%
% Group variables according to their symbol type
%
RequirePackage{ifthen} 
ifthenelse{equal{languagename}{english}}%
{ % English
    renewcommand{nomgroup}[1]{%
        ifthenelse{equal{#1}{R}}{%
            item[textbf{Roman symbols}]}{%
            ifthenelse{equal{#1}{G}}{%
                item[textbf{Greek symbols}]}{%
                ifthenelse{equal{#1}{S}}{%
                    item[textbf{Subscripts}]}{%
                    ifthenelse{equal{#1}{T}}{%
                        item[textbf{Superscripts}]}{}}}}}%
}{% Portuguese
    renewcommand{nomgroup}[1]{%
        ifthenelse{equal{#1}{R}}{%
            item[textbf{Simbolos romanos}]}{%
            ifthenelse{equal{#1}{G}}{%
                item[textbf{Simbolos gregos}]}{%
                ifthenelse{equal{#1}{S}}{%
                    item[textbf{Subscritos}]}{%
                    ifthenelse{equal{#1}{T}}{%
                        item[textbf{Sobrescritos}]}{}}}}}%
}%

% not in texliveusepackage[number=none]{glossary}
%setglossary{gloskip={}}
%makeglossary
usepackage{rotating}
usepackage[pdftex]{hyperref} % enhance documents that are to be
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%     Begin Document                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
begin{document}

% Set plain page style (no headers, footer with centered page number)
pagestyle{plain}

% Set roman numbering (i,ii,...) before the start of chapters
pagenumbering{roman}

%showtheabovedisplayskip
%showtheabovedisplayshortskip

% -----------------------------------------------------------------------------
subsection{Equations}
label{subsection:equations}

Equations can be inserted in different ways.

The simplest way is in a separate line like this
begin{equation}
frac{mathrm{d} q_{ijk}}{mathrm{d} t} + {cal R}_{ijk}(mathbf{q}) = 0 ,.
label{eq:ode}
end{equation}

If the equation is to be embedded in the text. One can do it like this ${partial {cal R}}/{partial mathbf{q}}=0$.

It may also be split in different lines like this
begin{eqnarray}
mathrm{Minimize}   && Y(mathbf{alpha},mathbf{q}(mathbf{alpha}))            nonumber           
mathrm{w.r.t.}     && mathbf{alpha} ,,                                 label{eq:minimize} 
mathrm{subject~to} && {cal R}(mathbf{alpha},mathbf{q}(mathbf{alpha})) = 0 nonumber           
&&       C (mathbf{alpha},mathbf{q}(mathbf{alpha})) = 0 ,. nonumber
end{eqnarray}

It is also possible to use subequations. Equations~ref{eq:continuity}, ref{eq:momentum} and ref{eq:energy} form the Naver--Stokes equations~ref{eq:NavierStokes}.

begin{subequations}
    begin{gather}
    frac{partial rho}{partial t} + frac{partial}{partial x_j}left( rho u_j right) = 0 ,,
    label{eq:continuity}

    frac{partial}{partial t}left( rho u_i right) + frac{partial}{partial x_j} left( rho u_i u_j + p delta_{ij} - tau_{ji} right) = 0, quad i=1,2,3 ,,
    label{eq:momentum}

    frac{partial}{partial t}left( rho E right) + frac{partial}{partial x_j} left( rho E u_j + p u_j - u_i tau_{ij} + q_j right) = 0 ,.
    label{eq:energy}
    end{gather}
    label{eq:NavierStokes}%
end{subequations}

% ----------------------------------------------------------------------
end{document}

Correct answer by David Carlisle on January 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP