Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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

share|improve this answer
    
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
add comment
\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}
share|improve this answer
    
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? –  Herbert 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 –  Herbert 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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