0

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.

enter image description here 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.

enter image description here

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!

2 Answers 2

4

Add my MWE using alignat enviroment of amsmath without a numbered equation.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}
\begin{alignat*}{6}
    u_{(1.1)0}^0 &= 0;\quad  &u_{(2.1)0}^0 &=  - 2;\quad  &u_{(2.2)0}^0 &= 2;\quad  &u_{(3.1)0}^0 &=  - 1;\quad &u_{(3.2)0}^0 &=  - 1;\quad  &u_{(4.1)0}^0 &= 0\\
     u_{(1.1)\xi}^0 &= -2;\quad  &u_{(2.1)\xi}^0&= 
     2;\quad  &u_{(2.2)\xi }^0  &= 2;\quad  &u_{(3.1)\xi}^0&=  3;\quad &u_{(3.2)\xi}^0  &=  - 3;\quad  &u_{(4.1)\xi}^0 &= 4
\end{alignat*}
\end{document}

enter image description here

..and with geometry package, you have the correct numbered equations.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage[margin=2cm]{geometry}
\begin{document}
\begin{alignat}{6}
    u_{(1.1)0}^0 &= 0;\quad  &u_{(2.1)0}^0 &=  - 2;\quad  &u_{(2.2)0}^0 &= 2;\quad  &u_{(3.1)0}^0 &=  - 1;\quad &u_{(3.2)0}^0 &=  - 1;\quad  &u_{(4.1)0}^0 &= 0\\
     u_{(1.1)\xi}^0 &= -2;\quad  &u_{(2.1)\xi}^0&= 
     2;\quad  &u_{(2.2)\xi }^0  &= 2;\quad  &u_{(3.1)\xi}^0&=  3;\quad &u_{(3.2)\xi}^0  &=  - 3;\quad  &u_{(4.1)\xi}^0 &= 4
\end{alignat}
\end{document}

enter image description here

4
  • Thank you for the quick response. Is there any way that the expressions can be printed with 4 columns or 5 columns without user intervention?
    – rajendra
    Commented Jul 25, 2020 at 14:48
  • @rajendra I think that the answer is ..yes but I am not able to make it. I'm sorry.
    – Sebastiano
    Commented Jul 25, 2020 at 14:51
  • I have solved the problem partially. Kindly check whether you can throw some light in solving the problem.
    – rajendra
    Commented Jul 26, 2020 at 6:42
  • @rajendra Excuse me, but I have given a comment before.
    – Sebastiano
    Commented Jul 26, 2020 at 7:57
1

Accidentally while searching for something else I have come across two solutions which are much simpler than expected.

Solution:1 One can use multicol package. From the documentation of the package. The working model is

\documentclass[a4paper,12pt]{article}
\usepackage{multicol}
\begin{document}
\begin{multicols}{3}
\noindent $u_{1.1 0}^0=-2;$\\
$u_{1.2 0}^0= 0;$\\
$u_{1.3 0}^0=2;$\\
\columnbreak
$u_{2.1 0}^0= 0$\\
$u_{3.1 0}^0=3;$\\ 
$u_{3.2 0}^0=-1;$\\
$u_{3.3 0}^0=-1;$\\
$u_{3.4 0}^0=3$\\
$u_{4.1 0}^0=-1;$\\
$u_{4.2 0}^0=-1;$\\
\end{multicols}
\end{document}

The sample output is enter image description here columnbreak can be used to break the column at the desired location. It is observed that sometimes one has to experiment a little based on the behaviour.

Solution :2 In multicol the items are arrange vertically. If one wants to do horizontally, they use the package tasks. The details can be found in align horizontally

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.