3

This is not an equation, it's just a long math line. I want to break it into lines with right alignment. I tried several solutions including align, multline, but somehow I can't get it to work properly. It always forces the text to center. If I use equation + split, it still force the text center. Is there a way to get rid of the centering property? Thank you.

Minimal example

\documentclass{article}
\usepackage{mathtools}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}

\begin{document}
    $X \times Y = \{$
            $\{a, b\}, \{a, c\}, \{a, e\}, \{a, f\},$ \\
            $\{b, b\}, \{b, c\}, \{b, e\}, \{b, f\},$ \\
            $\{c, b\}, \{c, c\}, \{c, e\}, \{c, f\},$ \\
            $\{d, b\}, \{d, c\}, \{d, e\}, \{d, f\} \}$ 
\end{document}

Edit (according to Stefan Kottwitz's solution) enter image description here

2

You could insert

\hspace*{\fill}

at the left of the lines with inline math to get right aligned inline math formulas.

Or use flalign*, such as

\begin{flalign*}
  X \times Y = \{&\\
  && \{a, b\}, \{a, c\}, \{a, e\}, \{a, f\}, \\
  && \{b, b\}, \{b, c\}, \{b, e\}, \{b, f\}, \\
  && \{c, b\}, \{c, c\}, \{c, e\}, \{c, f\}, \\
  && \{d, b\}, \{d, c\}, \{d, e\}, \{d, f\} \}
\end{flalign*}

Alternative, aligned at brace and all moved to the left:

\noindent Text
\begin{flalign*}
 X \times Y = \{&\{a, b\}, \{a, c\}, \{a, e\}, \{a, f\}, &\\
& \{b, b\}, \{b, c\}, \{b, e\}, \{b, f\}, &\\
& \{c, b\}, \{c, c\}, \{c, e\}, \{c, f\}, &\\
& \{d, b\}, \{d, c\}, \{d, e\}, \{d, f\} \}
\end{flalign*}

flalign example

  • Wow, you're quick. Thanks a lot ;). I tried your flalign* example, however, it makes the text align to the right, not left though :(. Is there a way to align make it align with the \{ above it? – Chan Aug 15 '11 at 8:51
  • @Chan: another example added – Stefan Kottwitz Aug 15 '11 at 12:02
  • Thanks again ;). By the way, if the line X times Y is actually the subsection title. I wonder if they could be in the same line? because the \begin and \end force a line break. How can I prevent this to happen? See my edit. – Chan Aug 15 '11 at 12:30
1
\documentclass{article}

    \usepackage{mathtools}
    
    
\begin{document}
    
\begin{multline}
            
X \times Y = \{
\{a, b\}, \{a, c\}, \{a, e\}, \{a, f\}, \\
                
\shoveright{\{b, b\}, \{b, c\}, \{b, e\}, \{b, f\},} \\
                
\shoveright{\{c, b\}, \{c, c\}, \{c, e\}, \{c, f\},} \\
                
\{d, b\}, \{d, c\}, \{d, e\}, \{d, f\} \} 
    
\end{multline}
    


\begin{align*}
\begin{split}
        X \times Y = \{
        &    \{a, b\}, \{a, c\}, \{a, e\}, \{a, f\}, \\
        &    \{b, b\}, \{b, c\}, \{b, e\}, \{b, f\}, \\
        &    \{c, b\}, \{c, c\}, \{c, e\}, \{c, f\}, \\
        &    \{d, b\}, \{d, c\}, \{d, e\}, \{d, f\} \} 
\end{split}
\end{align*}
\end{document}
  • Thank you. However, from the 2nd line up to end, they align in the middle not right to the \{. Any other idea? – Chan Aug 15 '11 at 8:56
  • @Chan: do you mean something like the edited answer? – user2478 Aug 15 '11 at 9:13
  • Yes, that almost is. However, I want the part X \times Y not centering though. Is there a way to force X \times Y to the left, and the rest move accordingly? Thanks again. – Chan Aug 15 '11 at 10:09
  • @Chan: see edit – user2478 Aug 15 '11 at 10:51
  • Thanks again. Unfortunately, it gave the same result, the first line is still centered. – Chan Aug 15 '11 at 11:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.