I have arranged a set of mathematical expressions using align
environment. For example,
\begin{flalign*}
u_{(1.1)0}^0 &= 0; &u_{(2.1)0}^0 &= - 2; &u_{(2.2)0}^0 &= 2; &u_{(3.1)0}^0 &= - 1; &u_{(3.2)0}^0 &= - 1; &u_{(4.1)0}^0 &= 0\\
u_{(1.1)\xi }^0 &= - 2; &u_{(2.1)\xi }^0 &= 2; &u_{(2.2)\xi }^0 &= 2; &u_{(3.1)\xi }^0 &= 3; &u_{(3.2)\xi }^0 &= - 3; &u_{(4.1)\xi }^0 &= 4
\end{flalign*}
For different page setups, sometimes these equations causes overflow from the print zone.
- Is there a simple algorithm that can print these equations with arbitrary number of columns?
Edit-1 The example is changed slightly to make the problem elegant.
\begin{alignat*}{3}
a&=fffffffffffffffffffffffff; &b&=gbbbbbbbbbbbbbbbbbbb; &c&=aaaaaaaaaaaaaaaaaaaaaa; \\
d&=ggggggggggggggggggggggggg; &f&=tttttttttttttttttttt; &t&=ssssssssssssssssssssss;
\end{alignat*}
The output generated with the above code (and also with align
) is shown below.
Since the expressions outside the margins cannot be printed, it forces the user to realign the expressions with 2 columns (here 2 is chosen arbitrarily by user based on individual case).
So, given a set of expressions, is there an algorithm or some code that can print the expressions with alignment within the number of columns given by the user without any intervention.
Edit-2 With a slight search in web, using some of the comments, the problem is slightly solved.
\newcounter{i}
\setcounter{i}{-1}
\newcount\col
\col=3
\foreach \ele in {1,2,3,...,15}
{
\ifnum \thei <\col
{
\ele\,
\addtocounter{i}{1}
}
\else
{
\setcounter{i}{0}
\\ \ele\,
} \fi
}
With the above code, the output is an matrix form as shown below.
Edit-3
While searching a topic, I found a few answers How to store a string. The idea is: define a command that takes a string. While running the loop, redefine the string command with the new string. Once the final string is obtained, use the string in the required environment and reset the string command to the first one.
I am not sure whether this is a proper way of doing and this works or not.
P.S.: There are many cases like this and very difficult to arrange these for each page setup!