1

Every time I'm working with tables in LaTeX, I'm frustrated, because I can't find a clean way to type them. Suppose my code looks like this:

\begin{tabular}{c c c}
  blablabla & blabla & bla blablabla \\
  bla & blablablablabla blabla & blabla blablabla \\
  blabla blabla blabla & bla & blablablabla bla \\
\end{tabular}

This looks dreadful in my code (imagine that there are even more columns and rows). I find it hard to read and quickly correct certain elements in it, if necessary. I therefore tried working with spaces and/or tabs to make it look like this:

\begin{tabular}{c c c}
  blablabla              & blabla                   & bla blablabla     \\
  bla                    & blablablablabla blabla   & blabla blablabla  \\
  blabla blabla blabla   & bla                      & blablablabla bla  \\
\end{tabular}

However, when I now need to change something, the alignment changes too and after a while, I'm rather typing spaces than doing something useful. The code in my editor (TeXstudio) is also displayed in Verdana (because I find that easier to read), but as it isn't monospaced, it doesn't even look that nicely aligned.

How do you guys manage this? Does it bother you too that the table should be aligned nicely in your code or am I the only freak out here?

darthbith
  • 7,384
Jeroen
  • 4,491
  • I use vim, a monospace font, naturally, and the easy-align plugin. I just mark the table and tell it to arrange everything with respect to the &s https://github.com/junegunn/vim-easy-align – MaxNoe Nov 22 '14 at 17:31
  • 1
    I use emacs it could align the entries but I never bother. If it is just ccc entries I let them fall as they fall. If it is p entries with paragraphs that kind of alignment doesn't work anyway. A simper alignment on the source, which does work also for p entries, is just to start each cell on a new line, ending the cell with & or \\ as needed – David Carlisle Nov 22 '14 at 17:35
  • I usually don't bother. But this is not a question about TeX. – egreg Nov 22 '14 at 17:41
  • I sometimes bother... and I sometimes don't. And I sometimes do it one way... and sometimes another... and sometimes not at all. If aligning it is taking more time than actually thinking about the content, I'd say you are bothering too much ;). Can you understand your code? Can you maintain it? I think that is more important than whether it somehow resembles the output (which seems more a WYSIWYG kind of thing). But this is not a TeX question, is it? – cfr Nov 22 '14 at 18:00
  • @cfr, egreg: You're right, this question isn't about TeX. I posted it anyway, because I sometimes read rather opinion based questions here. Maybe this can be moved to Meta or something? – Jeroen Nov 22 '14 at 18:03
  • 1
    You can use the Perl script latexindent to reformat and indent your code properly. – Werner Nov 22 '14 at 18:13
  • Without using a monospaced font it will very hard to get your desired perfect alignment. Like some others commnets, It´s not something that bothers me either. – Smarzaro Nov 22 '14 at 18:50
  • As a reference for people with the same question: I eventually installed a monospaced font and followed @Werner 's suggestion to use latexindent for automatic indentation, see https://tex.stackexchange.com/questions/334287/how-to-use-latexindent-in-texstudio-on-windows – Jeroen Jun 19 '20 at 11:46

0 Answers0