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.

I'm trying to add this expression to my work: Equation example

I understand that the best way to achieve this is using the alignat environment within the amsmath package, so I tried the following:

\begin{alignat*}{3}
m && \text{módulo} && m>0\\
a && \text{multiplicador} && 0<a<m\\
c && \text{constante aditiva} && 0\leq c<m\\
x_0 && \text{valor inicial} && 0\leq x_0 <m
\end{alignat*}

But the spacing I'm getting is really weird, I have read the amsmath documentation but I can't figure out what's the problem.

This was I'm getting: My results

My version is in spanish and I'm using polyglossia, but I don't think that's relevant. Anyway I'm using xelatex, and the book class.

I also wanted to know if there is a way to write the whole equation in the same environment with the middle text, or do I need to make another math environment for the centered equation at the end.

share|improve this question
4  
actually, looking at what you want to do, tabular or tabbing is probably a better approach than alignat. alignat sets up "columns" this way: <flush right> & <flush left> & <right> & <left> .... it was really designed to align multiple "mini-equations" across a line. you'd get a better result if you set your lines up (using the longest one as the example) c\qquad & \text{constante aditiva}\qquad & 0\leq c<m \` but that's still not wonderful. –  barbara beeton Mar 22 '12 at 18:38

1 Answer 1

up vote 25 down vote accepted

The important things to remember are that

  • alignat doesn't add space between the columns;
  • the columns are as many rl pairs as specified by the argument.

So, if you want left alignment for the symbols, the descriptions, and the conditions, you should place them after a &, with another & to separate the pairs:

\begin{alignat*}{3}
& m   \quad && \text{módulo}            \quad && m>0\\
& a   \quad && \text{multiplicador}     \quad && 0<a<m\\
& c   \quad && \text{constante aditiva} \quad && 0\leq c<m\\
& x_0 \quad && \text{valor inicial}     \quad && 0\leq x_0 <m
\end{alignat*}

By adding \quad we separate the columns. It wouldn't be necessary to specify them on all rows, but doing so spares to guess what is the widest entry.

However, this will center the whole alignment. You can get a non centered alignment using tabular (and the array package):

\begin{tabular}{@{}>{$}l<{$}l>{$}l<{$}@{}}
m   & módulo            & m>0\\
a   & multiplicador     & 0<a<m\\
c   & constante aditiva & 0\leq c<m\\
x_0 & valor inicial     & 0\leq x_0 <m
\end{tabular}
share|improve this answer

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.