Math & Sciencevertical spacing array environment

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Michael7496
Posts: 14
Joined: Thu Aug 15, 2013 9:42 am

vertical spacing array environment

Post by Michael7496 »

Hello,

here is a minimum example:

Code: Select all

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\begin{document}
	\begin{gather*}
		\begin{array}{c}
			\dfrac{a}{b}\\
			\dfrac{c}{d}
		\end{array}
	\end{gather*}
\end{document}
There is no space between b and c. I have a very large document and I'm using this very often. I want to change the minimum vertical distance between two characters in the array environment globally.

\arraystretch is not a global solution because:

Code: Select all

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}

\renewcommand*{\arraystretch}{6.0}

\begin{document}
	\begin{gather*}
		\begin{array}{rl}
			\begin{array}{c}
				\dfrac{a}{b \cdot \dfrac{a}{b \cdot \dfrac{a}{b \cdot \dfrac{a}{b}}}}\\
				\dfrac{a \cdot \dfrac{a \cdot \dfrac{a \cdot \dfrac{a}{b}}{b}}{b}}{b}\\
				\dfrac{c}{d}\\
				a = b
			\end{array}
			&
			\begin{array}{rl}
				a & $this is an a$\\
				b & $this in a b$\\
				c & $this is a c$\\
				d & $this is a d$
			\end{array}
		\end{array}
	\end{gather*}
\end{document}
I don't want to stretch the arrays.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
Michael7496
Posts: 14
Joined: Thu Aug 15, 2013 9:42 am

Re: vertical spacing array environment

Post by Michael7496 »

:'(
User avatar
Stefan Kottwitz
Site Admin
Posts: 10290
Joined: Mon Mar 10, 2008 9:44 pm

vertical spacing array environment

Post by Stefan Kottwitz »

The array environment could be redefined, but this would of course have effect to all array environments including matrices and cases.

Another tip: when I test your code, I see the symbols are too close to the fraction line and, and the lines are not justified to the right. This can be solved by using \cfrac instead, see: Wie schreibe ich einen Kettenbruch?

The second continued fraction seems to be differently treated by \cfrac, I'm sure this could be fixed in a new / followup question there too, if desired.

Stefan
LaTeX.org admin
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

vertical spacing array environment

Post by cgnieder »

I don't think a global adjustment is easily possible without having to redefine the internals of the array environment. I am not very familiar with the way array is defined (just know the basics) but the task seems to be a complex one, actually. One would need to measure the contents of cells in subsequent lines in order to come anywhere near a solution (unless I am completely off here?). This would mean a quite complex re-writing that a) takes the contents of the environment as an argument (and consequently making array into a pseudo-environment) and b) ... well I don't have an algorithm, yet. Honestly I am not planning to develop one, either.

By far the easiest way seems to me to use the optional argument of \\ where lines need adjusting. A document will need lots of little adjustments when it comes near to completion anyway, some much harder than cases like the one in the MWE.

If it were me, I'd simply go for something like this:

Code: Select all

\documentclass[12pt]{article}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}

\begin{document}
\begin{gather*}
  \begin{array}{rl}
    \begin{array}{c}
        \dfrac{a}{b \cdot \dfrac{a}{b \cdot \dfrac{a}{b \cdot \dfrac{a}{b}}}}
      \\[10ex]
        \dfrac{a \cdot \dfrac{a \cdot \dfrac{a \cdot \dfrac{a}{b}}{b}}{b}}{b}
      \\[3ex]
      \dfrac{c}{d} \\[2ex]
      a = b
    \end{array}
    &
    \begin{array}{rl}
      a & \text{this is an a} \\
      b & \text{this is an b} \\
      c & \text{this is an c} \\
      d & \text{this is an d} 
    \end{array}
  \end{array}
\end{gather*}
\end{document}
LaTeX is very good but it is not perfect :)

Regards
site moderator & package author
Michael7496
Posts: 14
Joined: Thu Aug 15, 2013 9:42 am

Re: vertical spacing array environment

Post by Michael7496 »

ok. Now we have understood that the array environment has to be redefined. If someone want to post his redefinition here he is welcomed. Other suggestions don't answer the posted question, I think so. If I make one, I will post it here.
Post Reply