Thoughts and problems with "Align ...

Anonymous
2012-08-29
2012-10-17

  • Anonymous
    2012-08-29

    This should probably be a bug report (or two), but since the formatting can be
    done better in this forum I'd like to open a discussion.

    Let us have the following code:

    \begin{tabular}{rcl}
        Col 1 & Col 2 & Col 3 \\
        some content... & more content... & a lot of content ... \\
    \end{tabular}
    

    Using the "Align Columns" function (button/menu/shortcut) we get:

    \begin{tabular}{rcl}
                  Col 1 &      Col 2      & Col 3                \\
        some content... & more content... & a lot of content ... \\
    \end{tabular}
    

    Great! It does align the columns' content according to the column
    specification (rcl). :)

    1. Parameters and commands following the linebreak command
    For the next step, I want a horizontal line between those two rows (\hline)
    and I need to append something to the third column's header:

    \begin{tabular}{rcl}
                  Col 1 &      Col 2      & Col 3 (Notes)               \\ \hline
        some content... & more content... & a lot of content ... \\
    \end{tabular}
    

    After aligning via "Align Columns" I have:

    \begin{tabular}{rcl}
                  Col 1 &      Col 2      & Col 3 (Notes)        \\
    \hline
        some content... & more content... & a lot of content ... \\
    \end{tabular}
    

    This is the first think I dislike: The algorithm moves everything after "\"
    to a blank line.
    Even an optional parameter as in

    \\[1ex]
    

    to add more space will be separated:

    \begin{tabular}{rcl}
                                Col 1 &      Col 2      & Col 3 (Notes)        \\
        [1ex]
    \hline
        some content... & more content... & a lot of content ... \\
    \end{tabular}
    

    Notice the missing indention before \hline. This blows the code up
    unnecessarily.

    Furthermore, when using the standard package booktabs a simple tabular like

    \begin{tabular}{rcl}
        \toprule
                  Col 1 &      Col 2      & Col 3 (Notes)        \\\midrule
        some content... & more content... & a lot of content ... \\\bottomrule
    \end{tabular}
    

    gets "aligned" to:

    \begin{tabular}{rcl}
        \toprule
                  Col 1 &      Col 2      & Col 3 (Notes)        \\
        \midrule
        some content... & more content... & a lot of content ... \\
                      \bottomrule &  \\
    \end{tabular}
    

    Notice the indention before \bottomrule, the extra ampersand and the linebreak
    command!
    Suggestion: Leave text behind the linebreak command alone and don't add more
    linebreaks.

     

  • Anonymous
    2012-08-29

    2. Column specification
    For example, the siunitx package provides the column specification \"S\" (for
    numbers) and \"s\" (for units):

    \\begin{tabular}{rcS}
                  Col 1 &      Col 2      & 123.45 \\\\
        some content... & more content... & 7.897  \\\\
    \\end{tabular}
    

    Both can have an optional parameter with key-value instructions. Texstudio
    seems to \"see\" another column when one uses the \"Align Columns\" function:

    \\begin{tabular}{rcS[key=value]}
                  Col 1 &      Col 2      & 123.45 &  \\\\
        some content... & more content... & 7.897  &  \\\\
    \\end{tabular}
    

    Notice the extra ampersand.
    Suggestion: Treat as a parameter (similar to {} in p{2cm}). Bonus: Align S
    columns at the decimal separator (can be a period and a comma).

    3. Alignment in math environments like align, alignat etc.
    As discussed in a previous feature request (Alignment of tables and equations
    at ampersand), I talked about problems with \intertext and the like.
    The alignment algorithm stopped working in math environments a long time ago.
    Are there any specific reasons for dropping this feature?

     

  • Anonymous
    2012-08-29

    4. Line Wrapping
    When handling tabulars (or math) environments the contents can get very long
    (using a lot of formatting commands and the like).
    Normally, I use soft line wrapping but for tabulars and/or math environments I
    would like to switch to no line wrapping and scroll horizontally.
    See the following (although contrived) example:

    I don't have a solution for this problem aside from manual formatting.
    Maybe: Shortcut for switching between soft and no line wrapping

     

  • Anonymous
    2012-08-29

    Post Scriptum:
    1. The optional argument even produces not aligned ampersands.
    2. I don't know why the second post has escape characters (multiple backshlashes) added to it.
    3. I had to split my post because the forum software "sensed" spam and I didn't know where.
    4. It is very annoying to work with the sourceforge interface.

     
  • Tim Hoffmann
    Tim Hoffmann
    2012-08-29

    Thanks for the comments. I will consider them.

    The Align-Table function is more a proof-of-concept right now. You may
    imagine, that parsing table code and also formating (multicolumn) can de quite
    complex. The current version works for a reasonable set of cases, but is far
    from beeing complete (and likely never will, considering the complexity of
    latex). It's designed to be extendable. However, you have to know all the
    possible cases and handle them correctly.

    Furthermore people have different ways of formating: \hline at beginning/end
    of a line/on a separate line; one column per line for large tables... It's not
    something you can make right for all people. Maybe I'll add configuration
    possibilities later.

     
  • Tim Hoffmann
    Tim Hoffmann
    2012-08-29

    Concerning the sf interface: It's not good, but it's all we have right now. sf
    will migrate to a new interface later this year. Hopefully things will get
    better then.

     

  • Anonymous
    2012-08-29

    t_hoffman
    You may imagine, that parsing table code and also formating (multicolumn) can
    de quite complex. It's not something you can make right for all people.

    This is one of the reason I didn't post this on the bug tracker but rather in
    the "Open Discussion" forum.
    There are too many possibilities that can mess up the algorithm.

    By the way, the following code shows a kind of workaround I often use (this is
    also a good way to comment columns):

    \begin{tabular}{rcl}
             \toprule % &                 &  \\
                  Col 1 &      Col 2      & Col 3 (Notes)        \\
             \midrule % &                 &  \\
        some content... & more content... & a lot of content ... \\
          \bottomrule % &                 &  \\
    \end{tabular}
    

    As far as I know, there aren't many (La)TeX editors out there that support
    automatic alignment. This is still better than nothing.

     
  • Tim Hoffmann
    Tim Hoffmann
    2012-10-01

    Issues 1 and 2 should now be fixed (rev. 3334). Also there are now options to
    specify some parameters of the alignment. They are located in Configure ->
    Advanced Editor.

    Issue 3: Alignment in math enviroments: Did it ever work? At least I did not
    officially write support for this so far. But is might have worked in a very
    early version, before the parser was changed to set up a complete model of the
    table.

    Issue 4: Line Wrapping. I don't have a solution for this either.
    @Shortcut for wrapping: It's currently not possible to make options available
    as menus/toolbar entries/shortcuts
    At least, there is now an option to format with one line per cell.