Align* environment. beautification.

  • Context: MHB 
  • Thread starter Thread starter caffeinemachine
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the use of the align* and array environments in LaTeX for formatting mathematical expressions. Participants are exploring ways to improve the visual presentation of their equations, particularly in the context of Mathjax compatibility and aesthetic preferences.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested

Main Points Raised

  • Some participants express dissatisfaction with the appearance of their equations using the align* environment and seek suggestions for improvement.
  • One participant shares an alternative using the array environment but notes that it does not compile properly in Mathjax due to specific formatting issues.
  • Another participant mentions the challenge of centering equations and expresses a desire to avoid an "inverted-triangular" shape in their layout.
  • Concerns are raised about the inability to tag equations within the array environment, with participants discussing potential workarounds.
  • A suggestion is made to create custom commands to facilitate tagging equations in the array environment, which some participants find useful.
  • One participant prefers left alignment and columnization for their equations, indicating a preference for a specific formatting style.

Areas of Agreement / Disagreement

There is no consensus on the best approach to formatting equations, as participants express varying preferences and face different challenges with their LaTeX environments. Multiple competing views remain regarding the use of align* versus array environments and the aesthetic outcomes of each.

Contextual Notes

Participants mention specific issues with Mathjax compatibility and the behavior of different LaTeX compilers, indicating that the effectiveness of proposed solutions may depend on the user's setup and preferences.

caffeinemachine
Gold Member
MHB
Messages
799
Reaction score
15
Using the align* environment I have the following output.
\begin{align*}
\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Rightarrow(\sigma_i\circ\varphi_i)^{-1}(j)&=(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Rightarrow\varphi_i^{-1}(\sigma_i^{-1}(j))&=\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Rightarrow\sigma_i^{-1}(j)&=\tau_i^{-1}(l)
\end{align*}

This looks ugly. How can I make it look better?
 
Physics news on Phys.org
caffeinemachine said:
Using the align* environment I have the following output.
\begin{align*}
\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Rightarrow(\sigma_i\circ\varphi_i)^{-1}(j)&=(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Rightarrow\varphi_i^{-1}(\sigma_i^{-1}(j))&=\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Rightarrow\sigma_i^{-1}(j)&=\tau_i^{-1}(l)
\end{align*}

This looks ugly. How can I make it look better?
Is this any better?

Code:
\begin{array}{rr@{\; = \;}l}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&\tau_i^{-1}(l)
\end{array}

It does not compile properly here, because Mathjax does not understand the @{\; = \;} specifier in the array description, and so the = signs get left out altogether. But it looks good in TeXShop.

The best I can do using Mathjax is

Code:
\begin{array}{rrcl}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&=&(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&=&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&=&\tau_i^{-1}(l)
\end{array}

That compiles under Mathjax as $$\begin{array}{rrcl}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&=&(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&=&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&=&\tau_i^{-1}(l)
\end{array}$$

which does not look good to me because there is too much space on each side of the = signs.
 
Opalg said:
Is this any better?

Code:
\begin{array}{rr@{\; = \;}l}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&\tau_i^{-1}(l)
\end{array}

It does not compile properly here, because Mathjax does not understand the @{\; = \;} specifier in the array description, and so the = signs get left out altogether. But it looks good in TeXShop.

The best I can do using Mathjax is

Code:
\begin{array}{rrcl}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&=&(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&=&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&=&\tau_i^{-1}(l)
\end{array}

That compiles under Mathjax as $$\begin{array}{rrcl}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&=&(\tau_i\circ\varphi_i)^{-1}(l),\forall i\in\{1,\ldots,r\}~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&=&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&=&\tau_i^{-1}(l)
\end{array}$$

which does not look good to me because there is too much space on each side of the = signs.

Thank you opalg. I want to use the first script since you say its better.. but my editor ain't able to compile it because of {rr@{\; = \;}l}. I am using TeXworks. Is there some package I need to download?
 
caffeinemachine said:
Thank you opalg. I want to use the first script since you say its better.. but my editor ain't able to compile it because of {rr@{\; = \;}l}. I am using TeXworks. Is there some package I need to download?
I don't know why some compilers fail to process the @-expression in an array environment. It is listed in the LaTeX User's Guide as a standard part of the system (see here, for example). On my Mac, the TeXShop compiler renders that code as
(Click on that thumbnail to see what it really looks like.)
 

Attachments

  • tex.gif
    tex.gif
    6.3 KB · Views: 125
Opalg said:
I don't know why some compilers fail to process the @-expression in an array environment. It is listed in the LaTeX User's Guide as a standard part of the system (see here, for example). On my Mac, the TeXShop compiler renders that code as
(Click on that thumbnail to see what it really looks like.)
Hmm.. It'd be great if we could "center" the LHS and RHS. This "inverted-triangular" shape it making it look bad. Any solution?
 
Opalg said:
I don't know why some compilers fail to process the @-expression in an array environment. It is listed in the LaTeX User's Guide as a standard part of the system (see here, for example). On my Mac, the TeXShop compiler renders that code as
(Click on that thumbnail to see what it really looks like.)
Now I understand how the array environment works. Centering makes it look worse. I'll go with the same as you have in the quoted text. Thanks.
 
Opalg said:
I don't know why some compilers fail to process the @-expression in an array environment. It is listed in the LaTeX User's Guide as a standard part of the system (see here, for example). On my Mac, the TeXShop compiler renders that code as
(Click on that thumbnail to see what it really looks like.)
I ran into another problem. The array environment works well when I want to manipulate my text.. but I am not able to tag my equations. \tag doesn't work. I also tried \hfill but that fails too. The only thing which seems to work is '~' but this is not practical. What can I do to label equations in the array environment?
 
caffeinemachine said:
I ran into another problem. The array environment works well when I want to manipulate my text.. but I am not able to tag my equations. \tag doesn't work. I also tried \hfill but that fails too. The only thing which seems to work is '~' but this is not practical. What can I do to label equations in the array environment?
You can pretty much tag anything if you add (below to your preamble):
Code:
\newcommand{\tagthisaux}{%                                                          
  \refstepcounter{equation}%                                                        
  (\theequation)%                                                                   
}
\newcommand{\tagthisline}{\`\tagthisaux}

Then at the end you would add:

Code:
\tagthisline

Example:
Code:
\begin{array}{ccc}
 & = & \tagthisline\\
 & = & 
\end{array}

The first line would be numbered and the second wouldn't. Additionally, the numbering convetion will follow in order to what you already have. That is, if you were on equation (1.2), that line would be (1.3).

I haven't looked at this post previously since it was marked solved. If it wasn't marked solved, I would have answered your last question sooner.
 
Last edited:
I usually prefer left aligned and to columnize everything:

\begin{array}{clclll}
&\bigcap_{i=1}^{r}(\sigma_i\circ\varphi_i)^{-1}(j)&=&\bigcap_{i=1}^{r}(\tau_i\circ\varphi_i)^{-1}(l)&\neq\emptyset\\
\Longrightarrow&(\sigma_i\circ\varphi_i)^{-1}(j)&=&(\tau_i\circ\varphi_i)^{-1}(l)&\forall i\in\{1,\ldots,r\}&~~~(\text{from prop. 9})\\
\Longrightarrow&\varphi_i^{-1}(\sigma_i^{-1}(j))&=&\varphi_i^{-1}(\tau_i^{-1}(l))\\
\Longrightarrow&\sigma_i^{-1}(j)&=&\tau_i^{-1}(l)
\end{array}
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 7 ·
Replies
7
Views
1K
  • · Replies 13 ·
Replies
13
Views
4K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 20 ·
Replies
20
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K