diff options
author | Karl Berry <karl@freefriends.org> | 2024-01-01 20:50:34 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2024-01-01 20:50:34 +0000 |
commit | 75b739cfeea6b5159a4d97c63dc210fec5ff1ae8 (patch) | |
tree | a130a1ca1f43eba5e14d22ad5511295583aa108c /Master/texmf-dist | |
parent | 4d8ff3b2a5b9ca8f62591a036088152d0e7e6879 (diff) |
freealign (1jan24)
git-svn-id: svn://tug.org/texlive/trunk@69267 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/freealign/README | 3 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/freealign/freealign.pdf | bin | 0 -> 51001 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/freealign/freealign.tex | 62 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/freealign/freealign.sty | 70 |
4 files changed, 135 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/freealign/README b/Master/texmf-dist/doc/latex/freealign/README new file mode 100644 index 00000000000..5ea9b1d1cde --- /dev/null +++ b/Master/texmf-dist/doc/latex/freealign/README @@ -0,0 +1,3 @@ +Package: Align math formulas in different lines +Author: Jianrui Lyu <tolvjr@163.com> +License: The LaTeX Project Public License 1.3c
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/freealign/freealign.pdf b/Master/texmf-dist/doc/latex/freealign/freealign.pdf Binary files differnew file mode 100644 index 00000000000..4a16b2551c6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/freealign/freealign.pdf diff --git a/Master/texmf-dist/doc/latex/freealign/freealign.tex b/Master/texmf-dist/doc/latex/freealign/freealign.tex new file mode 100644 index 00000000000..4c1a5944937 --- /dev/null +++ b/Master/texmf-dist/doc/latex/freealign/freealign.tex @@ -0,0 +1,62 @@ +% -*- 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} diff --git a/Master/texmf-dist/tex/latex/freealign/freealign.sty b/Master/texmf-dist/tex/latex/freealign/freealign.sty new file mode 100644 index 00000000000..a00717045c2 --- /dev/null +++ b/Master/texmf-dist/tex/latex/freealign/freealign.sty @@ -0,0 +1,70 @@ +% -*- coding: utf-8 -*- +% ---------------------------------------------------------------------------- +% Author: Jianrui Lyu <tolvjr@163.com> +% License: The LaTeX Project Public License 1.3c +% ---------------------------------------------------------------------------- + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{freealign}[2024-01-01 v2024A Align math formulas in different lines] + +\RequirePackage{etoolbox,zref-savepos} + +\@ifundefined{zsaveposx}{\let\zsaveposx\zsavepos}{} % 旧版本无 \zsaveposx 命令 + +\newcounter{saveposcnt} +\newcounter{useposcnt} +\renewcommand*{\thesaveposcnt}{savepos\number\value{saveposcnt}} +\renewcommand*{\theuseposcnt}{usepos\number\value{useposcnt}} + +\def\my@alignment@offset{} + +\def\my@alignment@list{} +\forcsvlist{\listadd\my@alignment@list}{=,<,>,\le,\ge,\leq,\geq,\approx} + +\newlength{\my@alignment@kern} + +\newcommand*{\my@alignment@check}[1]{% + \ifx\my@let@token #1% + \def\my@alignment@offset{5}% + \expandafter\listbreak + \fi +} + +\newcommand{\my@alignment@next}{% + \ifdefempty{\my@alignment@offset}{% + \def\my@alignment@offset{0}% + \forlistloop{\my@alignment@check}{\my@alignment@list}% + }{}% + \settowidth{\my@alignment@kern}{$\mkern\my@alignment@offset mu$}% + \stepcounter{saveposcnt}% + \rlap{\kern\my@alignment@kern\zsaveposx{\thesaveposcnt}}% +} + +\newcommand*{\tabpoint}[1][]{% + \leavevmode + \def\my@alignment@offset{#1}% + \futurelet\my@let@token\my@alignment@next +} +\let \? = \tabpoint + +\newcommand*{\tabto}{% + \stepcounter{useposcnt}% + \zsaveposx{\theuseposcnt}% + \noindent + \hskip\zposx{\thesaveposcnt}sp\relax + \hskip-\zposx{\theuseposcnt}sp\relax + \ignorespaces +} +\let \+ = \tabto + +\newcommand*{\tableft}{% + \settowidth{\my@alignment@kern}{$=\mkern5mu$}% + \stepcounter{useposcnt}% + \zsaveposx{\theuseposcnt}% + \noindent + \hskip\zposx{\thesaveposcnt}sp\relax + \hskip-\zposx{\theuseposcnt}sp\relax + \hskip-\my@alignment@kern + \ignorespaces +} +\let \< = \tableft |