Is the \begin{align} function available for the MaTeX package?

6

2

I would like to know if the MaTeX package from our colleague Szabolcs can align the calculation steps as possible by the code below:

\documentclass[a4paper]{article}

%% Language and font encodings
\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins
\usepackage[a4paper,top=3cm,bottom=2cm,left=3cm,right=3cm,marginparwidth=1.75cm]{geometry}

%% Useful packages
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage[colorlinks=true, allcolors=blue]{hyperref}

\title{Your Paper}
\author{You}

\usepackage{amsmath, amssymb}

\begin{document}

\begin{align}
V &= \int_0^H dV\\
  &= \int_0^H A'\,dh\\
  &= \int_0^H \frac{Ah^2}{H^2}\,dh\\
  &= \frac{A}{H^2}\left|\frac{h^3}{3}\right|_0^H\\
  &= \frac{A}{H^2}\cdot\frac{H^3}{3}\\
  &= \frac{1}{3}AH
\end{align}

\begin{equation}
V=\frac{A}{H^2}\left[\frac{h^3}{3}\right]_0^H
\end{equation}

\end{document}

enter image description here

Information: The above code is not for Mathematica software, but it is a reference for LaTeX language users.

The code below (this one yes) is what I would like to align in Mathematica software:

Needs["MaTeX`"]
MaTeX["\\int_0^r 2\\pi r\\,dr = 2\\pi \\int_0^r r\\,dr = \
2\\pi\\bigg\vert_0^r \\frac{r^2}{2} = \\bigg(2\\pi \
\\frac{r^2}{2}\\bigg)-\\bigg(2\\pi \\frac{0^2}{2}\\bigg) = \
\\frac{2\\pi r^2}{2} = \\ boldsymbol{\\pi r^2}"]

Is the \begin{align} function available in this package?

LCarvalho

Posted 2017-07-05T19:04:52.353

Reputation: 8 935

This is discussed both on the webpage you linked to and the builtin documentation. MaTeX interprets commands in inline mode, so align cannot be used. But aligned can, as @Nasser said. – Szabolcs – 2017-07-06T04:07:46.473

Answers

6

Use aligned from amsmath (I do not think align or align* works in Matex)

Needs["MaTeX`"]
SetOptions[MaTeX,"Preamble"->{"\\usepackage{amssymb,amsmath,latexsym,amsfonts,amsthm}"}]

Then

MaTeX["
\\begin{aligned}
V&= \\int_0^H dV\\\\
&= \\int_0^H A'\\,dh\\\\
&= \\int_0^H\\frac{Ah^2}{H^2}\\,dh\\\\
&= \\frac{A}{H^2}\\left|\\frac{h^3}{3}\\right|_0^H\\\\
&= \\frac{A}{H^2}\\cdot\\frac{H^3}{3}\\\\
&= \\frac{1}{3}AH
\\end{aligned}
"]

Gives

Mathematica graphics

Second example

MaTeX["
\\begin{aligned}
\\int_0^r 2\\pi r\\,dr &= 2\\pi \\int_0^r r\\,dr \\\\
&= 2\\pi\\bigg\\vert_0^r \\frac{r^2}{2} \\\\
&= \\bigg(2\\pi \\frac{r^2}{2}\\bigg)-\\bigg(2\\pi \\frac{0^2}{2}\\bigg) \\\\
&= \\frac{2\\pi r^2}{2} \\\\
&= \\boldsymbol{\\pi r^2}
\\end{aligned}
"]

Gives

Mathematica graphics

Nasser

Posted 2017-07-05T19:04:52.353

Reputation: 92 661

For kindness. Could you post using my second example? – LCarvalho – 2017-07-05T21:58:37.767

What you did is correct ... – LCarvalho – 2017-07-05T22:10:54.670

3

MaTeX interprets TeX commands in inline math mode. Only those commands work that are allowed in inline math mode.

As @Nasser said, in this case use aligned instead of align (and make sure that the amsmath package is loaded—it is in the default "BasePreamble" option value).

This is discussed both on the webpage you linked to, and the builtin documentation. Please check the documentation (in particular the Possible Issues section) when encountering problems like this. It has answers to the most common questions.

enter image description here

Szabolcs

Posted 2017-07-05T19:04:52.353

Reputation: 213 047

How nice. The father of this package has found my question. I disclose your package a lot. – LCarvalho – 2017-07-06T09:20:29.320