[Tex/LaTex] How to keep tables readable in code

best practicescodetables

What is the best practice for creating and updating tables in Latex? I am using Texmaker but I find it hard to update a table like adding entries or adding a column. I have to count entries which is kind of tedious.
Is it better to first create a table in an excel type program and import it when finished?
Example:

\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|}
\hline 
Study & Year & Method & • & • & • & • & • & o & Result num. & Result \\ 
\hline 
 • & • & autor & autor et al & autor. & autor & autor\cite{autor} & 

Best Answer

I write my tables always in a pretty printed form to be able to recognize colums and rows in the LaTeX code.

My best practice is:

  • I write one row in one line of my code (and if I need 200 characters)
  • I write all & below each other so that I can see in the code the columns of my table. I keeo this structure even if I have to use the macros \multirow or \multicolumn.
  • I write the end of a row (\\) below each other.
  • I keep the table in my TeX document

An example:

\begin{tabular}{r@{:}l*{5}c}
\toprule
\multicolumn{1}{c}{}    &       & \multicolumn{5}{c}{Node ID}                                                          \\ 
\cmidrule{3-7}
\multicolumn{2}{c}{Date | Time} & 25             & 28             & 29             & 31              & 32              \\
\midrule
9/29/2007 00            &00     & \ding{108}     & \ding{108}     & \ding{108}     & \ding{108}      & \ding{108}      \\
9/29/2007 01            &00     & \ding{109}     & \ding{109}     & \ding{109}     & \ding{109}      & \ding{109}      \\
9/29/2007 23            &00     & \ding{108}     & \ding{108}     & \ding{109}     & \ding{108}      & \ding{109}      \\
\midrule
9/29/2007 23            &00     & \textbullet    & \textbullet    & \textbullet    & \textopenbullet & \textopenbullet \\
\midrule
9/29/2007 23            &00     & $\blacksquare$ & $\blacksquare$ & $\blacksquare$ & $\square$       & $\square$       \\
Columns: 1              & 2     & 3              & 4              & 5              & 6               & 7               \\
\bottomrule
\end{tabular}

Writing your table in this way allows you to change rows or columns better. With a little practice you will see it is usable ...

I write all my tables in this way.