6
$\begingroup$

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?

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – Szabolcs
    Commented Jul 6, 2017 at 4:07

2 Answers 2

6
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ For kindness. Could you post using my second example? $\endgroup$
    – LCarvalho
    Commented Jul 5, 2017 at 21:58
  • $\begingroup$ What you did is correct ... $\endgroup$
    – LCarvalho
    Commented Jul 5, 2017 at 22:10
3
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ How nice. The father of this package has found my question. I disclose your package a lot. $\endgroup$
    – LCarvalho
    Commented Jul 6, 2017 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.