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.

(Too) Long ago, I had some problems with some equation. I wanted them to look like this

enter image description here

(this is how they looked in LyX), but when compiled they looked like this:

enter image description here.

What botheres me compared to how it looks in LyX is that

  1. way too much spacing between the columns is used in the compiled version.
  2. there isn't a space after the "="
  3. the last column is aligned to the right (not to the left, as I wanted it to be).

    Because only now I found time, to post this question here, I unfortunately don't remember the name of the environment used for this (I only kept the screenshots). But I remember that I tried out all of the AMS environments( align, alignat etc.) as well as the eqnarray environment and not a single one provided me with an output that looks like the one in LyX.

Has anyone an idea how I could get LaTeX make these (test)equations look like the LyX screenshot ?

share|improve this question
3  
Still it is not nice to answerers to leave the work of typing your example to them. Please provide example code containing the elements seen in the screenshots. It doesn't have to have the proper alignment, just show you attempted to solve it. –  Stephan Lehmke Apr 10 '12 at 14:17
add comment

2 Answers

up vote 8 down vote accepted

There are quite a few ways you could achieve your desired output- using the amsmath environments that you mentioned is certainly an option. Of course, you should make sure to avoid eqnarray as discussed in \eqnarray vs \align

Another option is to use the array environment

enter image description here

\documentclass{article}

\begin{document}

\[
\begin{array}{cccll}
    x< & a  & =     & 1     & i<j\\
    x< & b  & =     & 12        & <i<j\\
    x< & c  & =     & 123       & <i<j<k
\end{array}
\]
\end{document}

This has the advantage that you can easily control column spacing, for example

\begin{array}{c@{\hspace{1cm}}ccll}
        x< & a  & =     & 1     & i<j\\
        x< & b  & =     & 12        & <i<j\\
        x< & c  & =     & 123       & <i<j<k
\end{array}

gives

enter image description here

share|improve this answer
add comment

You can do this with aligned in LyX.

  1. Make a displayed equation, e.g. with Insert --> Math --> Display formula.
  2. Add an aligned environment within this, Insert --> Math --> Aligned Environment.
  3. By default there is two columns, add six extra columns with the button on the table toolbar or the keyboard shortcut Alt + MCI. There should then be eight columns.
  4. Fill the columns as such:
    1. Type x <
    2. Leave this empty
    3. Type a
    4. Leave this empty
    5. Leave this empty
    6. Type = 123
    7. Leave this empty
    8. Type <i<j<k

Below is a screenshot of the LyX view with source and the PDF output. Click to enlarge.

enter image description here

share|improve this answer
1  
I found no means of adjusting array alignments (column specifications) in LyX. Do you know of a way to do this? Great shortcoming of LyX if not possible? –  Werner Apr 10 '12 at 16:21
    
@Werner You can switch between l, c and r easily enough (alignment buttons on table toolbar), but I don't know if one can do more than that. I only open LyX to try and answer questions here though, so I don't know that much ... –  Torbjørn T. Apr 10 '12 at 16:35
    
Yes, I was able to switch between alignment, but was unable to use column specifications of the form @{}r@{\;}c@{\;}l, say. –  Werner Apr 10 '12 at 17:28
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.