texlive[41507] Master: autobreak (20jun16)

commits+karl at tug.org commits+karl at tug.org
Tue Jun 21 00:24:28 CEST 2016


Revision: 41507
          http://tug.org/svn/texlive?view=revision&revision=41507
Author:   karl
Date:     2016-06-21 00:24:28 +0200 (Tue, 21 Jun 2016)
Log Message:
-----------
autobreak (20jun16)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/latex/autobreak/
    trunk/Master/texmf-dist/doc/latex/autobreak/README.md
    trunk/Master/texmf-dist/doc/latex/autobreak/autobreak.pdf
    trunk/Master/texmf-dist/source/latex/autobreak/
    trunk/Master/texmf-dist/source/latex/autobreak/autobreak.dtx
    trunk/Master/texmf-dist/source/latex/autobreak/autobreak.ins
    trunk/Master/texmf-dist/tex/latex/autobreak/
    trunk/Master/texmf-dist/tex/latex/autobreak/autobreak.sty
    trunk/Master/tlpkg/tlpsrc/autobreak.tlpsrc

Added: trunk/Master/texmf-dist/doc/latex/autobreak/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/autobreak/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/latex/autobreak/README.md	2016-06-20 22:24:28 UTC (rev 41507)
@@ -0,0 +1,75 @@
+autobreak
+=========
+
+[![Build Status](https://img.shields.io/travis/tueda/autobreak/master.svg)](https://travis-ci.org/tueda/autobreak)
+
+This package implements a simple mechanism of line/page breaking
+within the `align` environment of the `amsmath` package; new line
+characters are considered as possible candidates for the breaks and
+the package tries to put breaks at adequate places. It is suitable
+for computer-generated long formulae with many terms.
+
+Example
+-------
+
+```latex
+\documentclass{article}
+\usepackage{amsmath}
+\usepackage{autobreak}
+\pagestyle{empty}
+\allowdisplaybreaks
+\begin{document}
+
+\begin{align}
+  \begin{autobreak}
+    \zeta(2) =
+    1
+    + \frac{1}{4}
+    + \frac{1}{9}
+    + \frac{1}{16}
+    + \frac{1}{25}
+    + \frac{1}{36}
+    + \frac{1}{49}
+    + \frac{1}{64}
+    + \frac{1}{81}
+    + \frac{1}{100}
+    + \frac{1}{121}
+    + \frac{1}{144}
+    + \frac{1}{169}
+    + \frac{1}{196}
+    + \frac{1}{225}
+    + \frac{1}{256}
+    + \frac{1}{289}
+    + \frac{1}{324}
+    + \frac{1}{361}
+    + \frac{1}{400}
+    + \frac{1}{441}
+    + \frac{1}{484}
+    + \frac{1}{529}
+    + \frac{1}{576}
+    + \frac{1}{625}
+    + \frac{1}{676}
+    + \frac{1}{729}
+    + \frac{1}{784}
+    + \frac{1}{841}
+    + \frac{1}{900}
+    + \dots
+  \end{autobreak}
+\end{align}
+
+\end{document}
+```
+
+![Example](https://github.com/tueda/autobreak/blob/images/example.png)
+
+
+Licence
+-------
+The LaTeX Project Public License 1.3 (or any later version)
+
+
+Bugs and remarks
+----------------
+Feedback is welcome on the Issue Tracker of GitHub:
+
+  https://github.com/tueda/autobreak/issues


Property changes on: trunk/Master/texmf-dist/doc/latex/autobreak/README.md
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/latex/autobreak/autobreak.pdf
===================================================================
(Binary files differ)

Index: trunk/Master/texmf-dist/doc/latex/autobreak/autobreak.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/latex/autobreak/autobreak.pdf	2016-06-20 22:23:22 UTC (rev 41506)
+++ trunk/Master/texmf-dist/doc/latex/autobreak/autobreak.pdf	2016-06-20 22:24:28 UTC (rev 41507)

Property changes on: trunk/Master/texmf-dist/doc/latex/autobreak/autobreak.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/autobreak/autobreak.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/autobreak/autobreak.dtx	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/autobreak/autobreak.dtx	2016-06-20 22:24:28 UTC (rev 41507)
@@ -0,0 +1,1130 @@
+% \iffalse meta-comment
+%
+% Copyright (C) 2016 by Takahiro Ueda <tueda at nikhef.nl>
+%
+% This file may be distributed and/or modified under the conditions of
+% the LaTeX Project Public License, either version 1.3 of this license
+% or (at your option) any later version. The latest version of this
+% license is in:
+%
+%    http://www.latex-project.org/lppl.txt
+%
+% and version 1.3 or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+% To typeset this document, type the following commands:
+%   latex autobreak.dtx
+%   makeindex -s gind.ist autobreak.idx
+%   makeindex -s gglo.ist -o autobreak.gls autobreak.glo
+%   latex autobreak.dtx
+%   latex autobreak.dtx
+%
+%<*ignore>
+\def\nameofplainTeX{plain}
+\ifx\fmtname\nameofplainTeX\else
+  \expandafter\begingroup
+\fi
+%</ignore>
+%<*install>
+
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+
+This is a generated file.
+
+Copyright (C) 2016 by Takahiro Ueda <tueda at nikhef.nl>
+
+This file may be distributed and/or modified under the conditions of
+the LaTeX Project Public License, either version 1.3 of this license
+or (at your option) any later version. The latest version of this
+license is in:
+
+  http://www.latex-project.org/lppl.txt
+
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+\endpreamble
+
+\generate{
+  \usedir{tex/latex/autobreak}
+  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
+}
+
+%</install>
+%<*ignore>
+\iffalse
+%</ignore>
+%<*install>
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{*                                                           *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX:                    *}
+\Msg{*                                                           *}
+\Msg{*     autobreak.sty                                         *}
+\Msg{*                                                           *}
+\Msg{* To produce the documentation run the file autobreak.dtx   *}
+\Msg{* through LaTeX.                                            *}
+\Msg{*                                                           *}
+\Msg{* Happy TeXing!                                             *}
+\Msg{*                                                           *}
+\Msg{*************************************************************}
+
+\endbatchfile
+
+%</install>
+%<*ignore>
+\fi
+\generate{
+  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
+}
+\ifx\fmtname\nameofplainTeX
+  \expandafter\endbatchfile
+\else
+  \expandafter\endgroup
+\fi
+%</ignore>
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[T1]{fontenc}
+\usepackage{lmodern}
+\usepackage{hypdoc}
+\usepackage{amsmath}
+\usepackage{autobreak}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+
+\allowdisplaybreaks
+
+% The default value of IndexColumns=3 never fits in pages.
+\setcounter{IndexColumns}{2}
+
+\providecommand\env[1]{\texttt{#1}}
+\providecommand\pkg[1]{\textsf{#1}}
+
+\usepackage{fancyvrb}
+
+\edef\examplefilename{\jobname.tmp}
+
+\newenvironment{example}{%
+  \VerbatimEnvironment
+  \begin{VerbatimOut}[gobble=2]{\examplefilename}%
+}{%
+  \end{VerbatimOut}%
+  \smallskip
+  \noindent
+  \begin{list}{}{}\item
+    \begin{minipage}[t]{0.45\linewidth}%
+      \VerbatimInput{\examplefilename}%
+    \end{minipage}%
+    \begin{minipage}[t]{0.5\linewidth}%
+      \input{\examplefilename}%
+    \end{minipage}%
+  \end{list}%
+  \smallskip
+  \noindent
+}
+
+\newenvironment{example*}{%
+  \VerbatimEnvironment
+  \begin{VerbatimOut}[gobble=2]{\examplefilename}%
+}{%
+  \end{VerbatimOut}%
+  \smallskip
+  \noindent
+  \begin{list}{}{}\item
+    \begin{minipage}[t]{0.95\linewidth}%
+      \VerbatimInput{\examplefilename}%
+    \end{minipage}%
+  \end{list}%
+  \smallskip
+  \noindent
+}
+
+\newenvironment{example**}{%
+  \VerbatimEnvironment
+  \begin{VerbatimOut}[gobble=2]{\examplefilename}%
+}{%
+  \end{VerbatimOut}%
+  \smallskip
+  \noindent
+  \begin{list}{}{}\item
+    \begin{minipage}[t]{0.95\linewidth}%
+      \VerbatimInput{\examplefilename}%
+    \end{minipage} \\
+    \begin{minipage}[t]{0.95\linewidth}%
+      \input{\examplefilename}%
+    \end{minipage}%
+  \end{list}%
+  \smallskip
+  \noindent
+}
+
+% decl from ltxguide[2001/05/28]
+\newenvironment{decl}[1][]%
+    {\par\small\addvspace{4.5ex plus 1ex}%
+     \vskip -\parskip
+     \ifx\relax#1\relax
+        \def\@decl at date{}%
+     \else
+        \def\@decl at date{\NEWfeature{#1}}%
+     \fi
+     \noindent\hspace{-\leftmargini}%
+     \begin{tabular}{|l|}\hline\ignorespaces}%
+    {\\\hline\end{tabular}\nobreak\@decl at date\par\nobreak
+     \vspace{2.3ex}\vskip -\parskip}
+
+\newcommand\NumberedBox[1]{%
+  \, \framebox[25pt]{#1} \,%
+}
+
+\newcommand\LongerNumberedBox[1]{%
+  \, \framebox[30pt]{#1} \,%
+}
+
+\begin{document}
+  \DocInput{\jobname.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{336}
+%
+% \CharacterTable
+%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%   Digits        \0\1\2\3\4\5\6\7\8\9
+%   Exclamation   \!     Double quote  \"     Hash (number) \#
+%   Dollar        \$     Percent       \%     Ampersand     \&
+%   Acute accent  \'     Left paren    \(     Right paren   \)
+%   Asterisk      \*     Plus          \+     Comma         \,
+%   Minus         \-     Point         \.     Solidus       \/
+%   Colon         \:     Semicolon     \;     Less than     \<
+%   Equals        \=     Greater than  \>     Question mark \?
+%   Commercial at \@     Left bracket  \[     Backslash     \\
+%   Right bracket \]     Circumflex    \^     Underscore    \_
+%   Grave accent  \`     Left brace    \{     Vertical bar  \|
+%   Right brace   \}     Tilde         \~}
+%
+% \GetFileInfo{\jobname.sty}
+%
+% \title{The \pkg{autobreak} package\thanks{This document corresponds
+%        to \pkg{autobreak}~\fileversion, dated \filedate.}}
+% \author{Takahiro Ueda}
+%
+% \date{19 June 2016}
+%
+% \maketitle
+%
+% \begin{abstract}
+%   This package implements a simple mechanism of line/page breaking
+%   within the \env{align} environment of the \pkg{amsmath} package; new
+%   line characters are considered as possible candidates for the breaks
+%   and the package tries to put breaks at adequate places.
+%   It is suitable for computer-generated long formulae with many terms.
+% \end{abstract}
+%
+% \changes{v0.1}{2016/06/03}{Initial version}
+%
+% \tableofcontents
+%
+% \section{Introduction}
+%
+% Sometimes people want to put long formulae in their documents, which
+% do not fit in a line and may span over multiple pages.
+% The following is an equation of explicitly writing down the first 50
+% terms in the sum of the well-known Basel problem:
+% \begin{align}
+% \begin{autobreak}
+% \zeta(2) =
+% 1
+% + \frac{1}{4}
+% + \frac{1}{9}
+% + \frac{1}{16}
+% + \frac{1}{25}
+% + \frac{1}{36}
+% + \frac{1}{49}
+% + \frac{1}{64}
+% + \frac{1}{81}
+% + \frac{1}{100}
+% + \frac{1}{121}
+% + \frac{1}{144}
+% + \frac{1}{169}
+% + \frac{1}{196}
+% + \frac{1}{225}
+% + \frac{1}{256}
+% + \frac{1}{289}
+% + \frac{1}{324}
+% + \frac{1}{361}
+% + \frac{1}{400}
+% + \frac{1}{441}
+% + \frac{1}{484}
+% + \frac{1}{529}
+% + \frac{1}{576}
+% + \frac{1}{625}
+% + \frac{1}{676}
+% + \frac{1}{729}
+% + \frac{1}{784}
+% + \frac{1}{841}
+% + \frac{1}{900}
+% + \frac{1}{961}
+% + \frac{1}{1024}
+% + \frac{1}{1089}
+% + \frac{1}{1156}
+% + \frac{1}{1225}
+% + \frac{1}{1296}
+% + \frac{1}{1369}
+% + \frac{1}{1444}
+% + \frac{1}{1521}
+% + \frac{1}{1600}
+% + \frac{1}{1681}
+% + \frac{1}{1764}
+% + \frac{1}{1849}
+% + \frac{1}{1936}
+% + \frac{1}{2025}
+% + \frac{1}{2116}
+% + \frac{1}{2209}
+% + \frac{1}{2304}
+% + \frac{1}{2401}
+% + \frac{1}{2500}
+% + \dots
+% \end{autobreak}
+% \end{align}
+% The above example might seem nonsense, but putting long formulae may
+% have a meaning in some cases and become inevitable for completeness of
+% documents, writing self-contained papers, or just to impress readers.
+% They are typically generated as outputs of computer algebra systems,
+% and would have the form of a sum of many terms while each term is
+% short.
+%
+% Then, the question is how to break long formulae in such a way that
+% the expressions do not make any overfull lines for \LaTeX{}.
+% Certainly, one can attempt to manually insert line breaks by trial and
+% error, checking whether \LaTeX{} warns overfull lines, and this
+% process could be automatized by external scripts at some extent.
+% A shortcoming of such `manual' approaches is that line breaks have to
+% be reexamined whenever the layout of the document is changed, e.g.,
+% replacing the document class or reusing existing equations into
+% another document with a different format.
+%
+% The goal of the \pkg{autobreak} package is to give a reasonably simple
+% solution for (semi-)automatic line breaking of long formulae within
+% \LaTeX{}^^A
+% \footnote{^^A
+%   There is another package \pkg{breqn}
+%   (\url{https://www.ctan.org/pkg/breqn}), which adopts a more
+%   automatic fashion and is useful for more sophisticated line
+%   breaking, unless you get ``Dimension too large'' error for really
+%   big expressions.
+% }.
+%
+% \section{Usage}
+%
+% The \pkg{autobreak} package is supposed to be used together with the
+% \pkg{amsmath} package^^A
+% \footnote{^^A
+%   \url{https://www.ctan.org/pkg/amsmath}.
+% }^^A
+% \footnote{^^A
+%   Actually \pkg{autobreak} internally loads \pkg{amsmath}, but it is
+%   still a good practice to explicitly include all packages providing
+%   macros used in your document.
+% }:
+% \begin{example*}
+%   \usepackage{amsmath}
+%   \usepackage{autobreak}
+% \end{example*}
+% When your document contains long equations over multiple pages,
+% you might want to use \cs{allowdisplaybreaks} of \pkg{amsmath}
+% package:
+% \begin{example*}
+%   \allowdisplaybreaks
+% \end{example*}
+%
+% \begin{decl}
+% |\begin{autobreak}| \\
+%   \meta{long-equations} \\
+% |\end{autobreak}|
+% \end{decl}
+% \SpecialEnvIndex{autobreak}
+% The \env{autobreak} environment is used for breaking lines in long
+% formulae in the \env{align} environment of \pkg{amsmath}^^A
+% \footnote{^^A
+%   Technically, \env{align} (with \cs{notag} to suppress equation
+%   numbers except the last line) is the only option we can use for
+%   page-break aligned equations within \pkg{amsmath} because
+%   \env{split}, \env{gathered}, \env{aligned} and \env{alginedat} do
+%   not allow page breaking.
+%   \env{dmath} of \env{breqn} with \cs{eqinterlinepenalty}\texttt{=0}
+%   allows page breaking, but may fail to find a reasonable tag place.
+% }.
+% \begin{example}
+%   \begin{align}
+%     \begin{autobreak}
+%       \zeta(3) =
+%       1
+%       + \frac{1}{8}
+%       + \frac{1}{27}
+%       + \frac{1}{64}
+%       + \frac{1}{125}
+%       + \frac{1}{216}
+%       + \frac{1}{343}
+%       + \frac{1}{512}
+%       + \frac{1}{729}
+%       + \frac{1}{1000}
+%       + \frac{1}{1331}
+%       + \frac{1}{1728}
+%       + \frac{1}{2197}
+%       + \frac{1}{2744}
+%       + \frac{1}{3375}
+%       + \frac{1}{4096}
+%       + \frac{1}{4913}
+%       + \frac{1}{5832}
+%       + \frac{1}{6859}
+%       + \frac{1}{8000}
+%       + \dots
+%     \end{autobreak}
+%   \end{align}
+% \end{example}
+% The magic happens from the simple fact that \env{autobreak} interprets
+% all new line characters appearing between |\begin{autobreak}| and
+% |\end{autobreak}| as \textit{breakable points}, at which any line
+% breaks can be logically inserted. To be more exact, the first
+% non-empty block, separated from the rest by a new line character,
+% determines the indentation of the successive lines. Then
+% \env{autobreak} tries to fill the line with the rest of the blocks,
+% and puts a line break when they do not fit in a line. This is
+% clarified by the following example:
+% \begin{example}
+%   \begin{align}
+%     \begin{autobreak}
+%       \NumberedBox{1}
+%       \NumberedBox{2}
+%       \NumberedBox{3}
+%       \NumberedBox{4}
+%       \NumberedBox{5}
+%       \NumberedBox{6}
+%       \NumberedBox{7}
+%       \NumberedBox{8}
+%       \NumberedBox{9}
+%       \NumberedBox{10}
+%       \NumberedBox{11}
+%     \end{autobreak}
+%   \end{align}
+% \end{example}
+%
+% It is also possible to put more than one \env{autobreak} in one
+% \env{align}:
+% \begin{example}
+%   \begin{align}
+%     \begin{autobreak}
+%       \NumberedBox{1} =
+%       \NumberedBox{2}
+%       + \NumberedBox{3}
+%       + \NumberedBox{4}
+%       + \NumberedBox{5}
+%       + \NumberedBox{6}
+%       + \NumberedBox{7}
+%       + \NumberedBox{8}
+%       + \NumberedBox{9}
+%       + \NumberedBox{10} ,
+%     \end{autobreak}
+%     \\
+%     \begin{autobreak}
+%       \LongerNumberedBox{1} =
+%       \NumberedBox{2}
+%       + \NumberedBox{3}
+%       + \NumberedBox{4}
+%       + \NumberedBox{5}
+%       + \NumberedBox{6}
+%       + \NumberedBox{7}
+%       + \NumberedBox{8}
+%       + \NumberedBox{9}
+%       + \NumberedBox{10} .
+%     \end{autobreak}
+%   \end{align}
+% \end{example}
+% For a technical reason, it often requires more than one run of
+% \LaTeX{}, and in such cases one will get informed by the following
+% warning:
+% \begin{example*}
+%   Package autobreak Warning: Layout may have changed.
+%   (autobreak)                Rerun to get layout correct.
+% \end{example*}
+% In the next run, the layout of the equations will be corrected.
+%
+% \begin{decl}
+% |\everybeforeautobreak| \marg{tokens} \\
+% |\everyaftereautobreak| \marg{tokens}
+% \end{decl}
+% \SpecialUsageIndex{\everybeforeautobreak}
+% \SpecialUsageIndex{\everyafterautobreak}
+% They specify token lists inserted before and after automatically
+% inserted line breaks in \env{autobreak}. For example,
+% \begin{example**}
+%   \begin{align}
+%     \everyafterautobreak{\times}
+%     \begin{autobreak}
+%       \cos\left(\frac{\pi x}{2}\right) =
+%       \left(1-x^2\right)
+%       \left(1-\frac{x^2}{9}\right)
+%       \left(1-\frac{x^2}{25}\right)
+%       \left(1-\frac{x^2}{49}\right)
+%       \left(1-\frac{x^2}{81}\right)
+%       \left(1-\frac{x^2}{121}\right)
+%       \left(1-\frac{x^2}{169}\right)
+%       \left(1-\frac{x^2}{225}\right)
+%       \left(1-\frac{x^2}{289}\right)
+%       \left(1-\frac{x^2}{361}\right)
+%       \left(1-\frac{x^2}{441}\right)
+%       \dots
+%     \end{autobreak}
+%   \end{align}
+% \end{example**}
+%
+% \section{Caveats}
+%
+% Because \env{autobreak} tries to insert line breaks at any of new line
+% characters, you must not make any new lines at which the line cannot
+% be broken^^A
+% \footnote{^^A
+%   You may put "\%" at the end of the line to avoid a new line.
+% }.
+% For example
+% \begin{example*}
+%   \begin{align}
+%     \begin{autobreak}
+%       x =
+%       % A problematic line break.
+%       \frac{1}
+%       {2} .
+%     \end{autobreak}
+%   \end{align}
+% \end{example*}
+% gives an error in the typesetting:
+% \begin{example*}
+%   ! Missing } inserted.
+%   <inserted text>
+%                   }
+%   l.8   \end{align}
+% \end{example*}
+%
+% Putting `|\\|' or `|&|' inside \env{autobreak}, which tries to insert
+% these special stuffs automatically, also causes typesetting errors.
+%
+% The \env{autobreak} environment uses \cs{linewidth} as the maximum
+% width that expressions in its body can occupy. There is no way for
+% \env{autobreak} to know how much other formulae consume the space
+% outside it. Therefore it fails to determine the adequate maximum
+% width when there are expressions outside \env{autobreak} and
+% then \LaTeX{} gives overfull line warnings:
+% \begin{example*}
+%   \begin{align}
+%     \text{some stuff outside autobreak}
+%     \begin{autobreak}
+%       \text{LHS} =
+%       ...
+%     \end{autobreak} .  % Even just a "." can be problematic.
+%   \end{align}
+%   % May give overfull line warnings
+% \end{example*}
+%
+% One may want to separate long formulae from the main document file to
+% other files and include them via \cs{input}\marg{file}, for example,
+% \begin{example*}
+%   \begin{align}
+%     \begin{autobreak}
+%       \input{longeqn.inc}  % It works!
+%     \end{autobreak}
+%   \end{align}
+%
+%   \begin{align}
+%     \begin{autobreak}
+%       lhs =
+%       \input{longrhs.inc}  % It also works!
+%       .
+%     \end{autobreak}
+%   \end{align}
+% \end{example*}
+% The current version of \env{autobreak} supports these cases: the file
+% content of \cs{input}\marg{file} is expanded before recognizing the
+% lines, with the help of the \pkg{catchfile} package^^A
+% \footnote{^^A
+%   \url{https://www.ctan.org/pkg/catchfile}.
+% },
+% when it appears at the beginning of each line. But it does not support
+% \cs{input}\marg{file} in the middle of the lines:
+% \begin{example*}
+%   \begin{align}
+%     \begin{autobreak}
+%       x + \input{longexpr.inc}  % Sorry, it does not work.
+%     \end{autobreak}
+%   \end{align}
+% \end{example*}
+% The difficulty comes from the fact that it needs to be expanded before
+% \env{autobreak} scans lines. By the same reason, \env{autobreak} fails
+% to detect new lines defined inside macros^^A
+% \footnote{^^A
+%   Actually, when the definition of \cs{foo} is parsed, the new line
+%   characters inside it are usually lost.
+% }:
+% \begin{example*}
+%   \newcommand{\foo}{
+%     a
+%     + b
+%     + c
+%     + d
+%   }
+%   \begin{align}
+%     \begin{autobreak}
+%       \foo + \foo + \foo + \foo  % No new lines can be detected.
+%     \end{autobreak}
+%   \end{align}
+% \end{example*}
+%
+% \StopEventually{^^A
+%   \PrintChanges
+%   \PrintIndex
+% }
+%
+% \section{Implementation}
+%
+%    \begin{macrocode}
+%<*package>
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{autobreak}%
+  [2016/06/03 v0.1 simple line breaking of long formulae]
+%    \end{macrocode}
+%
+% \subsection{Registers and constants}
+%
+% \begin{macro}{\everybeforeautobreak}
+% The list of tokens that gets inserted before every line break generated
+% by \env{autobreak}.
+%    \begin{macrocode}
+\newtoks\everybeforeautobreak
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\everyafterautobreak}
+% The list of tokens that gets inserted after every line break generated
+% by \env{autobreak}.
+%    \begin{macrocode}
+\newtoks\everyafterautobreak
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at alltoks}
+% The token register to store the whole result of \env{autobreak}.
+%    \begin{macrocode}
+\newtoks\@autobreak at alltoks
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at linetoks}
+% The token register for the current line.
+%    \begin{macrocode}
+\newtoks\@autobreak at linetoks
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at lhswidth}
+% The width of the current left-hand side.
+%    \begin{macrocode}
+\newdimen\@autobreak at lhswidth
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at rhswidth}
+% The width of the current right-hand side.
+%    \begin{macrocode}
+\newdimen\@autobreak at rhswidth
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at maxlhswidth}
+% The width of the longest left-hand side occupied. Affected by the
+% |.aux| file generated in the previous run.
+%    \begin{macrocode}
+\newdimen\@autobreak at maxlhswidth
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at realmaxlhswidth}
+% The width of the longest left-hand side occupied. Not affected by the
+% |.aux| file generated in the previous run.
+%    \begin{macrocode}
+\newdimen\@autobreak at realmaxlhswidth
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at maxrhswidth}
+% The maximum width that the right-hand sides can occupy.
+%    \begin{macrocode}
+\newdimen\@autobreak at maxrhswidth
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at sep}
+% The additional space needed for putting the left-hand side and the
+% right-hand side in one line, in other words, the separation for |&|.
+% TODO: how can we know the exact extra space to be inserted?
+%    \begin{macrocode}
+\def\@autobreak at sp{7\p@}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at newlinechar}
+% The macro representing an active |^^M|.
+%    \begin{macrocode}
+\begingroup
+  \catcode`\^^M=\active
+  \gdef\@autobreak at newlinechar{^^M}
+\endgroup
+%    \end{macrocode}
+% \end{macro}
+%
+% \subsection{Interaction with \texttt{.aux} files}
+%
+% When there are two or more \env{autobreak} in one \env{align}, each
+% \env{autobreak} has to know the maximum width of the left-hand side of
+% the all \env{autobreak} in the same \env{align}. Instead of violating
+% `causality' (e.g., how \LaTeX{} parses a file from the beginning to
+% the end), we use |.aux| file to store the maximum left-hand side
+% width, which provides the correct value in the next run.
+%
+% \begin{macro}{\if at autobreak@invalidlayout}
+% The switch to be turned on when an invalid layout is detected.
+%    \begin{macrocode}
+\newif\if at autobreak@invalidlayout
+\@autobreak at invalidlayoutfalse
+%    \end{macrocode}
+% \end{macro}
+% Show a warning if the user needs to rerun.
+%    \begin{macrocode}
+\AtEndDocument{%
+  \if at autobreak@invalidlayout
+    \if at filesw
+      \PackageWarningNoLine{autobreak}{Layout may have changed.
+        \MessageBreak Rerun to get layout correct}%
+    \else
+      \PackageWarningNoLine{autobreak}{Layout may be wrong}%
+    \fi
+  \fi
+}
+%    \end{macrocode}
+% \begin{macro}{\@autobreak at getmaxlhswidth}
+% To be expanded to a value saved in |.aux| in the previous run, or
+% |0pt| if not found.
+%    \begin{macrocode}
+\def\@autobreak at getmaxlhswidth#1{%
+  \@ifundefined{@autobreak at w@#1}{%
+    \z@
+  }{%
+    \@nameuse{@autobreak at w@#1}%
+  }%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at setmaxlhswidth}
+% Called in |.aux|.
+%    \begin{macrocode}
+\def\@autobreak at setmaxlhswidth#1#2{%
+  \global\@namedef{@autobreak at w@#1}{#2}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{@autobreak at eqnindex}
+% The counter to identify each \env{align}.
+%    \begin{macrocode}
+\newcounter{@autobreak at eqnindex}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{@autobreak at subeqnindex}
+% The counter to store the number of \env{autobreak} in an \env{align}.
+%    \begin{macrocode}
+  \newcounter{@autobreak at subeqnindex}[@autobreak at eqnindex]%
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at loadmaxlhswidth}
+% Loads \cs{@autobreak at maxlhswidth} for the next \env{align}.
+%    \begin{macrocode}
+\def\@autobreak at loadmaxlhswidth{%
+  \stepcounter{@autobreak at eqnindex}%
+  \@autobreak at maxlhswidth=%
+    \@autobreak at getmaxlhswidth{\arabic{@autobreak at eqnindex}}%
+  \@autobreak at realmaxlhswidth=\z@
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at savemaxlhswidth}
+% Saves \cs{@autobreak at realmaxlhswidth} for the next run.
+%    \begin{macrocode}
+\def\@autobreak at savemaxlhswidth{%
+  \ifnum\arabic{@autobreak at subeqnindex}>0
+    \ifdim\@autobreak at maxlhswidth=\@autobreak at realmaxlhswidth
+    \else
+%    \end{macrocode}
+% We have used the wrong value of \cs{@autobreak at maxlhswidth} (was too
+% much). Need to rerun.
+%    \begin{macrocode}
+      \global\@autobreak at invalidlayouttrue
+    \fi
+%    \end{macrocode}
+% Note that \cs{@autobreak at maxlhswidth} becomes problematic only when
+% two or more \env{autobreak} appear in one \env{align}. In the case
+% with one \env{autobreak}, the default value |0pt| is safe for the next
+% run.
+%    \begin{macrocode}
+    \ifnum\arabic{@autobreak at subeqnindex}>1
+      \if at filesw
+%    \end{macrocode}
+% We should provide \cs{@autobreak at setmaxlhswidth} in |.aux|.
+%    \begin{macrocode}
+        \@ifundefined{@autobreak at auxinited}{%
+          \immediate\write\@mainaux{%
+            \string\providecommand
+              \string\@autobreak at setmaxlhswidth[2]{}%
+          }%
+          \gdef\@autobreak at auxinited{}%
+        }{}%
+        \immediate\write\@auxout{%
+          \string\@autobreak at setmaxlhswidth%
+            {\arabic{@autobreak at eqnindex}}%
+            {\the\@autobreak at realmaxlhswidth}%
+        }%
+      \fi
+    \fi
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \subsection{Hacking \pkg{amsmath}}
+%
+%    \begin{macrocode}
+\RequirePackage{amsmath}
+%    \end{macrocode}
+%
+% \begin{macro}{\if at autobreak@newlinedef}
+% The switch to be turned on when \cs{@autobreak at newlinedef} applies.
+%    \begin{macrocode}
+\newif\if at autobreak@newlinedef
+\@autobreak at newlinedeffalse
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at newlinedef}
+% Installs the definition of |^^M| as a space. This is virtually
+% harmless in math mode.
+%    \begin{macrocode}
+\begingroup
+  \catcode`\^^M=\active
+  \gdef\@autobreak at newlinedef{%
+    \def^^M{ }%
+    \@autobreak at newlinedeftrue
+  }
+\endgroup
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\collect at body}
+% We need to override \cs{collect at body} such that it keeps |^^M|.
+%    \begin{macrocode}
+\def\collect at body#1{%
+  \@envbody={\expandafter#1\expandafter{\the\@envbody}}%
+  \edef\process at envbody{%
+    \the\@envbody\noexpand\end{\@currenvir}%
+  }%
+  \@envbody=\@emptytoks
+  \def\begin at stack{b}%
+  \begingroup
+%    \end{macrocode}
+% Actually, the following three lines need to be inserted to the
+% original code.
+%    \begin{macrocode}
+    \if at autobreak@newlinedef
+      \catcode`\^^M=\active
+    \fi
+    \expandafter\let\csname\@currenvir\endcsname=\collect@@body
+    \edef\process at envbody{%
+      \expandafter\noexpand\csname\@currenvir\endcsname
+    }%
+    \process at envbody
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{environment}{align}
+% Hack \env{align} of \pkg{amsmath}.
+%    \begin{macrocode}
+\let\@autobreak at oldstart@align=\start at align
+\def\start at align{%
+  \@autobreak at loadmaxlhswidth
+  \@autobreak at newlinedef
+  \@autobreak at oldstart@align
+}
+%    \end{macrocode}
+%    \begin{macrocode}
+\let\@autobreak at oldendalign=\endalign
+\def\endalign{%
+  \@autobreak at savemaxlhswidth
+  \@autobreak at oldendalign
+}
+%    \end{macrocode}
+% \end{environment}
+%
+% \subsection{\env{autobreak} environment}
+%
+% \begin{environment}{autobreak}
+% Checks if we are in \env{align} (and \cs{@autobreak at newlinedef} is
+% applied), increments the counter and collects its body via
+% \cs{collect at body}.
+%    \begin{macrocode}
+\newenvironment{autobreak}{%
+  \if at autobreak@newlinedef
+  \else
+    \PackageError{autobreak}{%
+      autobreak is not allowed here
+    }{%
+      Use autobreak inside align.
+    }%
+  \fi
+  \stepcounter{@autobreak at subeqnindex}%
+  \collect at body\@autobreak
+}{}
+%    \end{macrocode}
+% \end{environment}
+%
+% \begin{macro}{\@autobreak}
+% Called from \cs{collect at body}. The parameter |#1| is the whole body.
+% It takes also |#2| and |#3|, which are always \cs{end} and
+% |autobreak|, to remove them from the successive tokens.
+%    \begin{macrocode}
+\def\@autobreak#1#2#3{%
+%    \end{macrocode}
+% First, close the group of \env{autobreak}.
+%    \begin{macrocode}
+  \end{autobreak}%
+%    \end{macrocode}
+% Then parse the given body of the environment and construct lines to be
+% passed to \env{align}.
+%    \begin{macrocode}
+  \@autobreak at init
+  \def\@tempa{\expandafter\@autobreak at scanline
+    \@autobreak at newlinechar#1}%
+  \expandafter\@tempa\@autobreak at newlinechar\@autobreak at end
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at init}
+% Initialization.
+%    \begin{macrocode}
+\def\@autobreak at init{%
+  \@autobreak at alltoks={}%
+  \@autobreak at linetoks={}%
+  \@autobreak at lhswidth=\z@
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at end}
+% Finalization. It generates the whole lines in one go.
+%    \begin{macrocode}
+\def\@autobreak at end{%
+  \expandafter\@autobreak at addtoks\expandafter\@autobreak at alltoks
+    \expandafter{\the\@autobreak at linetoks}%
+  \the\@autobreak at alltoks
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at scanline}
+% Takes a line from the input stream. Here a line ends with |^^M|.
+%    \begin{macrocode}
+\begingroup
+  \catcode`\^^M=\active
+  \gdef\@autobreak at scanline#1^^M{\@autobreak at scanline@{#1}}
+\endgroup
+%    \end{macrocode}
+% If the next token is a punctuation, then we merge it into the current
+% line. (Otherwise it can make a line only with a period, for example).
+%    \begin{macrocode}
+\def\@autobreak at scanline@#1{%
+  \@autobreak at ifnextpunct{%
+    \@autobreak at scanline@gobble{#1}%
+  }{%
+    \@autobreak at scanline@@{#1}%
+  }%
+}
+%    \end{macrocode}
+% A helper macro of \cs{@ifnextpunct}\marg{if-yes}\marg{if-no}.
+%    \begin{macrocode}
+\def\@autobreak at ifnextpunct#1#2{%
+  \@ifnextchar.{%
+    #1%
+  }{%
+    \@ifnextchar,{%
+      #1%
+    }{%
+      \@ifnextchar;{%
+        #1%
+      }{%
+        \@ifnextchar:{%
+          #1%
+        }{%
+          #2%
+        }%
+      }%
+    }%
+  }%
+}
+%    \end{macrocode}
+% Merge punctuations as possible (usually there is only one period in a
+% line, though).
+%    \begin{macrocode}
+\def\@autobreak at scanline@gobble#1#2{%
+  \@autobreak at ifnextpunct{%
+    \@autobreak at scanline@gobble{#1#2}%
+  }{%
+    \@autobreak at scanline@@{#1#2}%
+  }%
+}
+%    \end{macrocode}
+% Pass the current line to \cs{@autobreak at processline}. Then, repeat
+% scanning lines until \cs{@autobreak at end} appears as the next token.
+%    \begin{macrocode}
+\def\@autobreak at scanline@@#1{%
+  \@autobreak at processline{#1}%
+  \@ifnextchar\@autobreak at end{}{%
+    \@autobreak at scanline@@@
+  }%
+}
+%    \end{macrocode}
+% One may expect \cs{input}\marg{file} in \env{autobreak} is expanded by
+% the file content and \env{autobreak} treats new lines in it correctly.
+% But it needs more work. Because handling of \cs{input} in the middle
+% of the lines is rather involved, for now we support only \cs{input} at
+% the beginning of each line (which is what sane people usually do).
+% This can be done via the \pkg{catchfile} package.
+%    \begin{macrocode}
+\IfFileExists{catchfile.sty}{
+  \RequirePackage{catchfile}
+  \def\@autobreak at scanline@@@{%
+    \@ifnextchar\input{%
+      \@autobreak at scanline@input
+    }{%
+      \@autobreak at scanline
+    }%
+  }
+}{
+  \def\@autobreak at scanline@@@{%
+    \@ifnextchar\input{%
+      \PackageWarning{autobreak}{%
+        Cannot handle new lines in a file via \protect\input,
+        \MessageBreak which requires the catchfile package
+      }%
+    }%
+    \@autobreak at scanline
+  }
+}
+%    \end{macrocode}
+% The argument |#1| is \cs{input} and |#2| is the file name.
+%    \begin{macrocode}
+\def\@autobreak at scanline@input#1#2{%
+  \CatchFileDef\@tempa{#2}{\catcode`\^^M=\active}%
+  \expandafter\@autobreak at scanline\@tempa
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at processline}
+% Each line from \cs{autobreak at scanline} should be regarded as a `block'
+% in the equation. The first block (typically the left-hand side $+$
+% `=') determines the indentation for the successive lines. From the
+% second block, try to append the block to the end of the line and
+% insert a line break if it does not fit in a line.
+%    \begin{macrocode}
+\def\@autobreak at processline#1{%
+  \ifdim\@autobreak at lhswidth=\z@
+%    \end{macrocode}
+% For the first block. The rest of the width for the right-hand sides
+% is determined from \cs{linewidth} and \cs{@autobreak at maxlhswidth}.
+%    \begin{macrocode}
+    \@autobreak at settowidth\@autobreak at lhswidth{#1}%
+    \ifdim\@autobreak at lhswidth>\z@
+      \ifdim\@autobreak at lhswidth>\@autobreak at maxlhswidth
+        \ifdim\@autobreak at maxlhswidth>\z@
+%    \end{macrocode}
+% The previous one used the wrong value of \cs{@autobreak at maxlhswidth}
+% (was too short). Need to rerun.
+%    \begin{macrocode}
+          \global\@autobreak at invalidlayouttrue
+        \fi
+        \global\@autobreak at maxlhswidth=\@autobreak at lhswidth
+      \fi
+      \ifdim\@autobreak at lhswidth>\@autobreak at realmaxlhswidth
+        \global\@autobreak at realmaxlhswidth=\@autobreak at lhswidth
+      \fi
+      \@autobreak at maxrhswidth=\linewidth
+      \advance\@autobreak at maxrhswidth by -\@autobreak at maxlhswidth
+      \advance\@autobreak at maxrhswidth by -\@autobreak at sp
+      \@autobreak at alltoks={#1{}&}%
+    \fi
+  \else
+%    \end{macrocode}
+% For the rest of the blocks.
+%    \begin{macrocode}
+    \@autobreak at settowidth\@autobreak at rhswidth
+      {\the\@autobreak at linetoks#1\the\everybeforeautobreak}%
+    \ifdim\@autobreak at rhswidth>\@autobreak at maxrhswidth
+%    \end{macrocode}
+% Adding the next block gives an overfull line. Need a line break.
+%    \begin{macrocode}
+      \edef\@tempa{\the\@autobreak at linetoks\the\everybeforeautobreak}%
+      \expandafter\@autobreak at addtoks\expandafter\@autobreak at alltoks
+        \expandafter{\@tempa\notag\\&}%
+      \@autobreak at linetoks=\everyafterautobreak
+    \fi
+    \@autobreak at addtoks\@autobreak at linetoks{#1}%
+  \fi
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at addtoks}
+% Appends |#2| to the token register |#1|.
+%    \begin{macrocode}
+\def\@autobreak at addtoks#1#2{%
+  #1=\expandafter{\the#1#2}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@autobreak at settowidth}
+% Same as \cs{settowidth} but in math mode. We assume \cs{displaystyle}.
+% (Anyway \env{align} issues \cs{displaystyle} at the beginning of every
+% cell.)
+%    \begin{macrocode}
+\def\@autobreak at settowidth#1#2{%
+  \settowidth#1{$\displaystyle#2$}%
+}
+%    \end{macrocode}
+% \end{macro}
+%
+%    \begin{macrocode}
+%</package>
+%    \end{macrocode}
+% \Finale
+\endinput


Property changes on: trunk/Master/texmf-dist/source/latex/autobreak/autobreak.dtx
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/source/latex/autobreak/autobreak.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/autobreak/autobreak.ins	                        (rev 0)
+++ trunk/Master/texmf-dist/source/latex/autobreak/autobreak.ins	2016-06-20 22:24:28 UTC (rev 41507)
@@ -0,0 +1,70 @@
+%%
+%% This is file `autobreak.ins',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% autobreak.dtx  (with options: `install')
+%% 
+%% This is a generated file.
+%% 
+%% Copyright (C) 2016 by Takahiro Ueda <tueda at nikhef.nl>
+%% 
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in:
+%% 
+%%   http://www.latex-project.org/lppl.txt
+%% 
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%% 
+
+\input docstrip.tex
+\keepsilent
+\askforoverwritefalse
+\preamble
+
+This is a generated file.
+
+Copyright (C) 2016 by Takahiro Ueda <tueda at nikhef.nl>
+
+This file may be distributed and/or modified under the conditions of
+the LaTeX Project Public License, either version 1.3 of this license
+or (at your option) any later version. The latest version of this
+license is in:
+
+  http://www.latex-project.org/lppl.txt
+
+and version 1.3 or later is part of all distributions of LaTeX
+version 2005/12/01 or later.
+
+\endpreamble
+
+\generate{
+  \usedir{tex/latex/autobreak}
+  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
+}
+
+
+\obeyspaces
+\Msg{*************************************************************}
+\Msg{*                                                           *}
+\Msg{* To finish the installation you have to move the following *}
+\Msg{* file into a directory searched by TeX:                    *}
+\Msg{*                                                           *}
+\Msg{*     autobreak.sty                                         *}
+\Msg{*                                                           *}
+\Msg{* To produce the documentation run the file autobreak.dtx   *}
+\Msg{* through LaTeX.                                            *}
+\Msg{*                                                           *}
+\Msg{* Happy TeXing!                                             *}
+\Msg{*                                                           *}
+\Msg{*************************************************************}
+
+\endbatchfile
+
+\endinput
+%%
+%% End of file `autobreak.ins'.

Added: trunk/Master/texmf-dist/tex/latex/autobreak/autobreak.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/autobreak/autobreak.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/latex/autobreak/autobreak.sty	2016-06-20 22:24:28 UTC (rev 41507)
@@ -0,0 +1,266 @@
+%%
+%% This is file `autobreak.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% autobreak.dtx  (with options: `package')
+%% 
+%% This is a generated file.
+%% 
+%% Copyright (C) 2016 by Takahiro Ueda <tueda at nikhef.nl>
+%% 
+%% This file may be distributed and/or modified under the conditions of
+%% the LaTeX Project Public License, either version 1.3 of this license
+%% or (at your option) any later version. The latest version of this
+%% license is in:
+%% 
+%%   http://www.latex-project.org/lppl.txt
+%% 
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+%% 
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{autobreak}%
+  [2016/06/03 v0.1 simple line breaking of long formulae]
+\newtoks\everybeforeautobreak
+\newtoks\everyafterautobreak
+\newtoks\@autobreak at alltoks
+\newtoks\@autobreak at linetoks
+\newdimen\@autobreak at lhswidth
+\newdimen\@autobreak at rhswidth
+\newdimen\@autobreak at maxlhswidth
+\newdimen\@autobreak at realmaxlhswidth
+\newdimen\@autobreak at maxrhswidth
+\def\@autobreak at sp{7\p@}
+\begingroup
+  \catcode`\^^M=\active
+  \gdef\@autobreak at newlinechar{^^M}
+\endgroup
+\newif\if at autobreak@invalidlayout
+\@autobreak at invalidlayoutfalse
+\AtEndDocument{%
+  \if at autobreak@invalidlayout
+    \if at filesw
+      \PackageWarningNoLine{autobreak}{Layout may have changed.
+        \MessageBreak Rerun to get layout correct}%
+    \else
+      \PackageWarningNoLine{autobreak}{Layout may be wrong}%
+    \fi
+  \fi
+}
+\def\@autobreak at getmaxlhswidth#1{%
+  \@ifundefined{@autobreak at w@#1}{%
+    \z@
+  }{%
+    \@nameuse{@autobreak at w@#1}%
+  }%
+}
+\def\@autobreak at setmaxlhswidth#1#2{%
+  \global\@namedef{@autobreak at w@#1}{#2}%
+}
+\newcounter{@autobreak at eqnindex}
+  \newcounter{@autobreak at subeqnindex}[@autobreak at eqnindex]%
+\def\@autobreak at loadmaxlhswidth{%
+  \stepcounter{@autobreak at eqnindex}%
+  \@autobreak at maxlhswidth=%
+    \@autobreak at getmaxlhswidth{\arabic{@autobreak at eqnindex}}%
+  \@autobreak at realmaxlhswidth=\z@
+}
+\def\@autobreak at savemaxlhswidth{%
+  \ifnum\arabic{@autobreak at subeqnindex}>0
+    \ifdim\@autobreak at maxlhswidth=\@autobreak at realmaxlhswidth
+    \else
+      \global\@autobreak at invalidlayouttrue
+    \fi
+    \ifnum\arabic{@autobreak at subeqnindex}>1
+      \if at filesw
+        \@ifundefined{@autobreak at auxinited}{%
+          \immediate\write\@mainaux{%
+            \string\providecommand
+              \string\@autobreak at setmaxlhswidth[2]{}%
+          }%
+          \gdef\@autobreak at auxinited{}%
+        }{}%
+        \immediate\write\@auxout{%
+          \string\@autobreak at setmaxlhswidth%
+            {\arabic{@autobreak at eqnindex}}%
+            {\the\@autobreak at realmaxlhswidth}%
+        }%
+      \fi
+    \fi
+  \fi
+}
+\RequirePackage{amsmath}
+\newif\if at autobreak@newlinedef
+\@autobreak at newlinedeffalse
+\begingroup
+  \catcode`\^^M=\active
+  \gdef\@autobreak at newlinedef{%
+    \def^^M{ }%
+    \@autobreak at newlinedeftrue
+  }
+\endgroup
+\def\collect at body#1{%
+  \@envbody={\expandafter#1\expandafter{\the\@envbody}}%
+  \edef\process at envbody{%
+    \the\@envbody\noexpand\end{\@currenvir}%
+  }%
+  \@envbody=\@emptytoks
+  \def\begin at stack{b}%
+  \begingroup
+    \if at autobreak@newlinedef
+      \catcode`\^^M=\active
+    \fi
+    \expandafter\let\csname\@currenvir\endcsname=\collect@@body
+    \edef\process at envbody{%
+      \expandafter\noexpand\csname\@currenvir\endcsname
+    }%
+    \process at envbody
+}
+\let\@autobreak at oldstart@align=\start at align
+\def\start at align{%
+  \@autobreak at loadmaxlhswidth
+  \@autobreak at newlinedef
+  \@autobreak at oldstart@align
+}
+\let\@autobreak at oldendalign=\endalign
+\def\endalign{%
+  \@autobreak at savemaxlhswidth
+  \@autobreak at oldendalign
+}
+\newenvironment{autobreak}{%
+  \if at autobreak@newlinedef
+  \else
+    \PackageError{autobreak}{%
+      autobreak is not allowed here
+    }{%
+      Use autobreak inside align.
+    }%
+  \fi
+  \stepcounter{@autobreak at subeqnindex}%
+  \collect at body\@autobreak
+}{}
+\def\@autobreak#1#2#3{%
+  \end{autobreak}%
+  \@autobreak at init
+  \def\@tempa{\expandafter\@autobreak at scanline
+    \@autobreak at newlinechar#1}%
+  \expandafter\@tempa\@autobreak at newlinechar\@autobreak at end
+}
+\def\@autobreak at init{%
+  \@autobreak at alltoks={}%
+  \@autobreak at linetoks={}%
+  \@autobreak at lhswidth=\z@
+}
+\def\@autobreak at end{%
+  \expandafter\@autobreak at addtoks\expandafter\@autobreak at alltoks
+    \expandafter{\the\@autobreak at linetoks}%
+  \the\@autobreak at alltoks
+}
+\begingroup
+  \catcode`\^^M=\active
+  \gdef\@autobreak at scanline#1^^M{\@autobreak at scanline@{#1}}
+\endgroup
+\def\@autobreak at scanline@#1{%
+  \@autobreak at ifnextpunct{%
+    \@autobreak at scanline@gobble{#1}%
+  }{%
+    \@autobreak at scanline@@{#1}%
+  }%
+}
+\def\@autobreak at ifnextpunct#1#2{%
+  \@ifnextchar.{%
+    #1%
+  }{%
+    \@ifnextchar,{%
+      #1%
+    }{%
+      \@ifnextchar;{%
+        #1%
+      }{%
+        \@ifnextchar:{%
+          #1%
+        }{%
+          #2%
+        }%
+      }%
+    }%
+  }%
+}
+\def\@autobreak at scanline@gobble#1#2{%
+  \@autobreak at ifnextpunct{%
+    \@autobreak at scanline@gobble{#1#2}%
+  }{%
+    \@autobreak at scanline@@{#1#2}%
+  }%
+}
+\def\@autobreak at scanline@@#1{%
+  \@autobreak at processline{#1}%
+  \@ifnextchar\@autobreak at end{}{%
+    \@autobreak at scanline@@@
+  }%
+}
+\IfFileExists{catchfile.sty}{
+  \RequirePackage{catchfile}
+  \def\@autobreak at scanline@@@{%
+    \@ifnextchar\input{%
+      \@autobreak at scanline@input
+    }{%
+      \@autobreak at scanline
+    }%
+  }
+}{
+  \def\@autobreak at scanline@@@{%
+    \@ifnextchar\input{%
+      \PackageWarning{autobreak}{%
+        Cannot handle new lines in a file via \protect\input,
+        \MessageBreak which requires the catchfile package
+      }%
+    }%
+    \@autobreak at scanline
+  }
+}
+\def\@autobreak at scanline@input#1#2{%
+  \CatchFileDef\@tempa{#2}{\catcode`\^^M=\active}%
+  \expandafter\@autobreak at scanline\@tempa
+}
+\def\@autobreak at processline#1{%
+  \ifdim\@autobreak at lhswidth=\z@
+    \@autobreak at settowidth\@autobreak at lhswidth{#1}%
+    \ifdim\@autobreak at lhswidth>\z@
+      \ifdim\@autobreak at lhswidth>\@autobreak at maxlhswidth
+        \ifdim\@autobreak at maxlhswidth>\z@
+          \global\@autobreak at invalidlayouttrue
+        \fi
+        \global\@autobreak at maxlhswidth=\@autobreak at lhswidth
+      \fi
+      \ifdim\@autobreak at lhswidth>\@autobreak at realmaxlhswidth
+        \global\@autobreak at realmaxlhswidth=\@autobreak at lhswidth
+      \fi
+      \@autobreak at maxrhswidth=\linewidth
+      \advance\@autobreak at maxrhswidth by -\@autobreak at maxlhswidth
+      \advance\@autobreak at maxrhswidth by -\@autobreak at sp
+      \@autobreak at alltoks={#1{}&}%
+    \fi
+  \else
+    \@autobreak at settowidth\@autobreak at rhswidth
+      {\the\@autobreak at linetoks#1\the\everybeforeautobreak}%
+    \ifdim\@autobreak at rhswidth>\@autobreak at maxrhswidth
+      \edef\@tempa{\the\@autobreak at linetoks\the\everybeforeautobreak}%
+      \expandafter\@autobreak at addtoks\expandafter\@autobreak at alltoks
+        \expandafter{\@tempa\notag\\&}%
+      \@autobreak at linetoks=\everyafterautobreak
+    \fi
+    \@autobreak at addtoks\@autobreak at linetoks{#1}%
+  \fi
+}
+\def\@autobreak at addtoks#1#2{%
+  #1=\expandafter{\the#1#2}%
+}
+\def\@autobreak at settowidth#1#2{%
+  \settowidth#1{$\displaystyle#2$}%
+}
+\endinput
+%%
+%% End of file `autobreak.sty'.


Property changes on: trunk/Master/texmf-dist/tex/latex/autobreak/autobreak.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2016-06-20 22:23:22 UTC (rev 41506)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2016-06-20 22:24:28 UTC (rev 41507)
@@ -49,7 +49,7 @@
     assignment assoccnt astro asyfig
     asymptote-faq-zh-cn asymptote-by-example-zh-cn asymptote-manual-zh-cn
     asypictureb attachfile
-    aucklandthesis augie auncial-new aurical autopdf
+    aucklandthesis augie auncial-new aurical autobreak autopdf
     authoraftertitle authorindex
     auto-pst-pdf autoarea automata autonum autosp avantgar avremu
   b1encoding babel

Added: trunk/Master/tlpkg/tlpsrc/autobreak.tlpsrc
===================================================================
Modified: trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc	2016-06-20 22:23:22 UTC (rev 41506)
+++ trunk/Master/tlpkg/tlpsrc/collection-mathextra.tlpsrc	2016-06-20 22:24:28 UTC (rev 41507)
@@ -6,6 +6,7 @@
 #
 depend 12many
 depend amstex
+depend autobreak
 depend backnaur
 depend begriff
 depend binomexp



More information about the tex-live-commits mailing list