%  -*- coding: utf-8 -*-
\documentclass[oneside,12pt]{article}
\usepackage[a4paper,margin=2cm]{geometry}

\newcommand*{\myversion}{2024A}
\newcommand*{\mydate}{Version \myversion\ (\the\year-\mylpad\month-\mylpad\day)}
\newcommand*{\mylpad}[1]{\ifnum#1<10 0\the#1\else\the#1\fi}

\setlength{\parindent}{0pt}
\setlength{\parskip}{4pt plus 1pt minus 1pt}

\usepackage{freealign}
\usepackage{codehigh}
\usepackage{hyperref}
\hypersetup{
  colorlinks=true,
  urlcolor=blue3,
  linkcolor=green3,
}


\begin{document}

\title{\textsf{\color{green3}FreeAlign: Align math formulas in different lines}}
\author{Jianrui Lyu (tolvjr@163.com)}
\date{\mydate}
\maketitle

This package provides several commands for aligning math formulas in different lines.
Here is the first example:

\vskip1em\hrule
We have $(a+b)^2 \? = (a+b)(a+b)$ \\
                 \+$= a^2+2ab+b^2$\hfill$\cdots\cdots$2 points
\vskip0.6em\hrule\vskip0.5em
\begin{codehigh}
We have $(a+b)^2 \? = (a+b)(a+b)$ \\
                 \+$= a^2+2ab+b^2$\hfill$\cdots\cdots$2 points
\end{codehigh}

The \verb!\?! command \underline{inside} the first formula saves current horizontal position,
and the \verb!\+! command \underline{before} the second formula jumps to previously saved position.

Here is another example:

\vskip1em\hrule
We have \? $(a+b)^2 = (a+b)(a+b)$ \\
        \< $= a^2+2ab+b^2$ \hfill$\cdots\cdots$2 points
\vskip0.6em\hrule\vskip0.5em
\begin{codehigh}
We have \? $(a+b)^2 = (a+b)(a+b)$ \\
        \< $= a^2+2ab+b^2$ \hfill$\cdots\cdots$2 points
\end{codehigh}

The \verb!\?! command \underline{before} the first formula saves current horizontal position,
and the \verb!\<! command \underline{before} the second formula jumps to the left
of previously saved position by the width of $=$.

Because this package uses \verb!zref! package to save positions,
you need two compilations to get correct results.

\end{document}
