4

LaTeX's fantastic for writing out papers with mathematics and mathematical results in them, but I've never really learned how to use it to type up calculations, as one would write them on a piece of paper, or a blackboard.

TL;DR is there a "paragraph mode" for mathematics?

What I mean by this is, when I write out my calculations, I usually want them in a display style, that is, I want the larger integral and summation signs, and the larger fractions, I want the limits above and below the symbols, that sort of thing, as you would write maths on a blackboard or a piece of homework.

The problem is, if you're writing out calculations, I was always taught to write them like, essentially, individual paragraphs. I was to have them flush with the left margin and I was to leave a line (or at least, some space) between each line of my calculation.

Clearly, consecutive \[ ... \]s are ill-suited to this and not just because of the centring. Suppose we have line 1, then line 2, and the left hand side of the = sign is different on each line, but then we wish to have an aligned equation, like this:

\[
  36V^{2} = A^{2}x^{2} - 2Ax^{4}
\]
\[
  V = \frac{1}{6}(A^{2}x^{2} - 2Ax^{4})^{\frac{1}{2}}
\]
\begin{flalign*}
  \frac{dV}{dx} &= \frac{2A^{2}x - 8Ax^{3}}{12\sqrt{A^{2}x^{2} -
      2Ax^{4}}} \\[12pt]
  &= \frac{A^{2}x - 4Ax^{3}}{6\sqrt{A^{2}x^{2} - 2Ax^{4}}}
\end{flalign*}

enter image description here

How are we to ensure consistent spacing between each line?

Traditionally I have used a bit of a hack, with its own imperfections.

\documentclass[fleqn,12pt]{article}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\setlength{\mathindent}{0pt}

\begin{document}

$\begin{displaystyle}
  36V^{2} = A^{2}x^{2} - 2Ax^{4} \\[12pt]
  V = \frac{1}{6}(A^{2}x^{2} - 2Ax^{4})^{\frac{1}{2}}
\end{displaystyle}$
\begin{flalign*}
  \frac{dV}{dx} &= \frac{2A^{2}x - 8Ax^{3}}{12\sqrt{A^{2}x^{2} -
      2Ax^{4}}} \\[12pt]
  &= \frac{A^{2}x - 4Ax^{3}}{6\sqrt{A^{2}x^{2} - 2Ax^{4}}}
\end{flalign*}

\end{document}

enter image description here

But I'm not longer confident this is ideal.

What I really want is:

  • All lines flush with the left margin
  • Perfectly consistent gap between all lines, including between single, independent lines of mathematics, each line in an aligned environment, the last independent single line and the first line of an aligned environment, and text
  • Display style
  • Ability to switch freely between aligned and unaligned maths and text

For example:

\documentclass[fleqn,12pt]{article}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\mathindent}{0pt}

\begin{document}

Let the volume of the container be denoted~$V$ and let the area be
denoted~$A$.

$\begin{displaystyle}
  36V^{2} = A^{2}x^{2} - 2Ax^{4} \\[\parskip]
  V = \frac{1}{6}(A^{2}x^{2} - 2Ax^{4})^{\frac{1}{2}}
\end{displaystyle}$
\begin{flalign*}
  \frac{dV}{dx} &= \frac{2A^{2}x - 8Ax^{3}}{12\sqrt{A^{2}x^{2} -
      2Ax^{4}}} \\[\parskip]
  &= \frac{A^{2}x - 4Ax^{3}}{6\sqrt{A^{2}x^{2} - 2Ax^{4}}}
\end{flalign*}
\begin{flalign*}
  \frac{dV}{dx} = 0 &\implies A^{2}x = 4Ax^{3} \\[\parskip]
  &\implies x = 0 \text{ or } x^{2} = \frac{A}{4} \\[\parskip]
  &\implies x = 0,\ \pm\frac{\sqrt{A}}{2}
\end{flalign*}
We discard $x = 0$ and $x = -\sqrt{A}/2$ since the length of the base
of the container can be neither 0 nor negative.

$\therefore$ $V$ is a maximum at $x = \sqrt{A}/2$.

\end{document}

enter image description here

What I'm aiming for is (in so far as possible) precisely this, but with perfectly even spacing between all lines and, if possible, a less ghastly source code. I mean \\[\parskip] (or, until recently, \\[12pt]) at the end of almost every line was okay before I read LaTeX: A Document Preparation System but now I feel like I must be doing something wrong!

  • 1
    \begin{displaystyle}? Where did you find this? – egreg Jul 28 '16 at 23:17
  • @egreg It's a fossil! It's really the same effect as $\displaystyle ...$ but environment structures make the source code easier to understand than switches and it allows me to break lines and keep the displaystyle going on and on and on over page breaks if necessary, which is what I want, really, I want a printed page that would look like a student's maths homework, or a professor's blackboard – Au101 Jul 28 '16 at 23:19
  • Fossil or not, use the proper form. It doesn't go on and on over page breaks: \displaystyle is obeyed only in the single (sub)formula it's in. – egreg Jul 28 '16 at 23:20
  • @egreg which would you consider proper, the switch, or just \[ ... \] or something else? I never looked up anything different, because my hack worked, hence now asking the question – Au101 Jul 28 '16 at 23:21
  • @egreg I don't know if we're on the same page or not, but try $\begin{displaystyle} \frac{A}{B} = \frac{C}{D} \\[12pt] \frac{A}{B} = \frac{C}{D} \\[12pt] ... \frac{A}{B} = \frac{C}{D} \end{displaystyle}$ It will span page breaks if you have enough lines! – Au101 Jul 28 '16 at 23:30
2

If you really need to this then instead of using the parskip package you might try using a document class that is designed for this type of layout. One example comes from the Dutch TeX user group in the ntgclass collection. Using their artikel3 class with the fleqn option, setting the \mathindent to zero and using just standard amsmath environments equation(*), align(*) and split gives many of the features you request.

Sample output

\documentclass[fleqn,12pt]{artikel3}

\usepackage{amsmath}
\usepackage{amssymb}
\setlength{\mathindent}{0pt}

\begin{document}

Let the volume of the container be denoted~$V$ and let the area be
denoted~$A$.

\begin{equation*}
  36V^{2} = A^{2}x^{2} - 2Ax^{4}
\end{equation*}
\begin{equation*}
  V = \frac{1}{6}(A^{2}x^{2} - 2Ax^{4})^{\frac{1}{2}}
\end{equation*}
\begin{equation*}
  \begin{split}
  \frac{dV}{dx} &= \frac{2A^{2}x - 8Ax^{3}}{12\sqrt{A^{2}x^{2} -
      2Ax^{4}}} \\
  &= \frac{A^{2}x - 4Ax^{3}}{6\sqrt{A^{2}x^{2} - 2Ax^{4}}}
  \end{split}
\end{equation*}
\begin{align*}
  \frac{dV}{dx} = 0 &\implies A^{2}x = 4Ax^{3} \\
  &\implies x = 0 \text{ or } x^{2} = \frac{A}{4} \\
  &\implies x = 0,\ \pm\frac{\sqrt{A}}{2}
\end{align*}
We discard $x = 0$ and $x = -\sqrt{A}/2$ since the length of the base
of the container can be neither 0 nor negative.

$\therefore$ $V$ is a maximum at $x = \sqrt{A}/2$.

\end{document}

Note that there is a big difference whether there is a blank line or not between two consecutive display math environments in the source.

Another example is the classes from the koma bundle, which have a parskip option.
The code would be the same as above, just with the first line changed to e.g.

\documentclass[fleqn,12pt,parskip=full*]{scrartcl}

There are quite a number of different choices for the parskip value. See the bundles documentation for full information.

On the other hand I would strongly discourage writing in this way. Sequences of equations without intervening text giving the structure of the arguments is not good for the reader (including yourself). I would be strongly inclined to write something more in this style:

Sample output

\documentclass[a4paper,12pt]{article}

\usepackage[margin=1.8cm]{geometry}

\usepackage{amsmath}
\usepackage{amssymb}

\begin{document}

Let the volume of the container be~$V$ and let the area~$A$.  Write
$x$ for the length of the base of the container.  We assume all three
quantities are strictly positive.

The geometry of the problem gives
  \begin{equation*}
  36V^{2} = A^{2}x^{2} - 2Ax^{4}
\end{equation*}
which we may solve to get
\begin{equation}
  \label{eq:V}
  V = \frac{1}{6}(A^{2}x^{2} - 2Ax^{4})^{1/2}.
\end{equation}

At a maximum we have \( dV/dx = 0 \).  Computing the derivative of
\eqref{eq:V}, we find
\begin{equation*}
  \begin{split}
    \frac{dV}{dx}
    &= \frac{2A^{2}x - 8Ax^{3}}{12\sqrt{A^{2}x^{2} - 2Ax^{4}}} \\
    &= \frac{A^{2}x - 4Ax^{3}}{6\sqrt{A^{2}x^{2} - 2Ax^{4}}}\\
    &= \frac{1}{6\sqrt{A^{2}x^{2} - 2Ax^{4}}} Ax(A-4x^2).
  \end{split}
\end{equation*}
So at a maximum either \( A = 0 \) or \( x = 0 \) or \( x = \pm \sqrt
A /2 \).  The positivity assumptions rule out the three cases \( A = 0
\), \( x = 0 \) and \( x = - \sqrt A/2 \), so the only candidate for a
maximum is at \( x = \sqrt A/2 \).

Now we explain why this is in fact a maximum and not some other critical
point\dots

\end{document}
  • 1
    This seems very very promising, thank you :) Also, I appreciate the pointers about adding text, very sound advice, I think, to anybody writing up their calculations formally :) For me personally, I suppose all I'm aiming for is a way to type up answers to exercises in maths textbooks, like you'd write them out in an exercise book. Indeed, I used to type my maths homework in secondary school (high school) and I guess LaTeX was really designed for the professional job, whereas I probably wouldn't write out that much explanation in answer to a simple calculus homework question. perhaps I should! – Au101 Aug 3 '16 at 10:44
  • I guess that second solution is better as it uses traditional/popular packages. – Wings Aug 2 at 12:44

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.