2

I am writing equations in array environments, but when there are fractions in some lines, the vertical space between these lines is too small. See this example:

enter image description here

for the following code:

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}
\usepackage{setspace}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}
\begin{document}
\[
\begin{array}{l}
    \dfrac{2-x}{x^2-16}=\dfrac{3}{x^2+4x}\\ 
    \dfrac{2-x}{(x+4)(x-4)}=\dfrac{3}{x(x+4)}\\
    \dfrac{x(2-x)}{x(x+4)(x-4)}=\dfrac{3(x-4)}{x(x+4)(x-4)}\\
    x(2-x)=3(x-4)\\
    2x-x^2=3x-12\\
    0=x^2+x-12\\
    0=(x+4)(x-3)\\
\end{array}
\]
\end{document}

I could adapt each line space by using \\[15pt] (for instance) or any vertical space at the end of the line, but this means that I have to do it for every line containing a fraction, which is a bit boring.

Another option is to use \def\arraystretch{2.7} (for instance) but then although the vertical spaces between lines with fractions is good, the vertical space between lines without fractions is too big. See this example:

enter image description here

With the following code:

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}
\usepackage{setspace}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}
\begin{document}
\[\def\arraystretch{2.7}
\begin{array}{l}
        \dfrac{2-x}{x^2-16}=\dfrac{3}{x^2+4x}\\ 
        \dfrac{2-x}{(x+4)(x-4)}=\dfrac{3}{x(x+4)}\\
        \dfrac{x(2-x)}{x(x+4)(x-4)}=\dfrac{3(x-4)}{x(x+4)(x-4)}\\
        x(2-x)=3(x-4)\\
        2x-x^2=3x-12\\
        0=x^2+x-12\\
        0=(x+4)(x-3)\\
\end{array}
\]
\end{document}

So my question is: in an array environment, is there a way to set space between text, and not between rows? Something that would set the space between the top of the row and the top of the text, and between the bottom of the text and the bottom of the row. Maybe for the whole document? I hope I am clear enough... Thank you anyway for your help and attention!

What I am willing should also work for more complicated equations, like this one:

enter image description here

with this code:

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}
\usepackage{setspace}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}
\begin{document}
        \[
\begin{array}{lll|l}
    \multicolumn{2}{l}{\dfrac{2-x}{x^2-16}=\dfrac{3}{x^2+4x}}       &   &\\%[.4cm]
    \multicolumn{2}{l}{\dfrac{2-x}{(x+4)(x-4)}=\dfrac{3}{x(x+4)}}   &   &\\%[.4cm]
    \multicolumn{2}{l}{\dfrac{x(2-x)}{x(x+4)(x-4)}=\dfrac{3(x-4)}{x(x+4)(x-4)}} &   &\cdot x(x-4)(x+4)\quad (\neq 0\mbox{ car }x\in\mathcal{D}_x)\\[.4cm]
    \multicolumn{2}{l}{x(2-x)=3(x-4)} & &\\%[.4cm]
    \multicolumn{2}{l}{2x-x^2=3x-12}    &   &\\%[.4cm]
    \multicolumn{2}{l}{0=x^2+x-12}      &   &\\%[.4cm]
    \multicolumn{2}{l}{0=(x+4)(x-3)}    &   &\\%[.4cm]
    \mbox{Soit }    &x+4=0              &   &-4\\%[.4cm]
    &x=-4               &   &\notin\mathcal{D}_x\\%[.4cm]
    \mbox{Soit }    &x-3=0              &   &+3\\%[.4cm]
    &x=3                &   &\in\mathcal{D}_x\\%[.4cm]
\end{array}
\]
\end{document}
4
  • 1
    array is not designed for displayed equations. It is much better to use align* from amsmath it has better spacing and is displaymath so you would not need \dfrac Jul 25, 2022 at 18:21
  • Off-topic: left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm may be expressed more simply as margin=2.5cm.
    – Mico
    Jul 25, 2022 at 19:33
  • Thank you for your advice! Unfortunately, I don't think the align* environment would work, because I also have some more complicated equations - see my last example here above, in my edited question. See also my previous question here: tex.stackexchange.com/questions/651780/… I really think I should work on vertical spaces in array environment. But if it really is not possible, I could live with adapting the space for each line with the command \\[15pt] or the vertical space I like...
    – Garulfo
    Jul 25, 2022 at 19:44
  • @ Mico: thanks for the tip!
    – Garulfo
    Jul 25, 2022 at 19:57

1 Answer 1

1

You can define a new column type f that adds some extra vertical space under the baseline. I'd also increase (locally) \arraystretch to give a more open look.

Look at the fixes: you just need three columns, not four.

\documentclass[12pt,a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{array}
\usepackage[left=2.50cm, right=2.50cm, top=2.50cm, bottom=2.50cm]{geometry}

\begin{document}
\[
\renewcommand{\arraystretch}{1.2}
\newcolumntype{f}{>{\rule[-3ex]{0pt}{3ex}}l}
\begin{array}{ll|l}
\multicolumn{2}{f|}{\dfrac{2-x}{x^2-16}=\dfrac{3}{x^2+4x}}     & \\
\multicolumn{2}{f|}{\dfrac{2-x}{(x+4)(x-4)}=\dfrac{3}{x(x+4)}} & \\
\multicolumn{2}{f|}{\dfrac{x(2-x)}{x(x+4)(x-4)}=\dfrac{3(x-4)}{x(x+4)(x-4)}} & 
  {}\cdot x(x-4)(x+4)\quad (\neq 0\mbox{ car }x\in\mathcal{D}_x) \\
\multicolumn{2}{l|}{x(2-x)=3(x-4)} & \\
\multicolumn{2}{l|}{2x-x^2=3x-12}  & \\
\multicolumn{2}{l|}{0=x^2+x-12}    & \\
\multicolumn{2}{l|}{0=(x+4)(x-3)}  & \\
\mbox{Soit} &x+4=0 & -4\\
            &x=-4  & \notin\mathcal{D}_x \\
\mbox{Soit} &x-3=0 & {}+3 \\
            &x=3   & \in\mathcal{D}_x \\
\end{array}
\]

\end{document}

enter image description here

1
  • Thank you for this solution. It seems good, but it also means that I have to write \multicolumn each time I use a fraction in an equation, and also when there is only one column. I think it would be easier to use \\[15pt] after lines with fractions. Is there really no general solution to set the vertical spaces correctly in array environment for the whole document?
    – Garulfo
    Jul 26, 2022 at 9:50

You must log in to answer this question.

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