It's not clear that there is really an issue to be solved, it is only an issue for tables if you think there is an issue about tables. Most of the points that you raise could also be made about "paragraphs" or "lists", at some point you have to have some structural information as well as words.
It is easy to have an environment that defaults the column spec, consider for example the amsmath matrix
which is more or less just array
with a default supplied preamble of *{20}{c}
so you could define
\newenvironment{mytab}[1][*{50}{c}]{%
\begin{tabular}{#1}}{%
\end{tabular}}
which makes the column specifications optional, defaulting to all centred. Unlike matrices though where a global default is commonly useful, in my experience a global table default is almost never useful, tables usually have varied column types, some textual, some numeric to be aligned on decimal points, etc. However if in a particular document you have a lot of tables all taking the same form you could use a definition as above, replacing *{50}{c}
by say >{\bfseries}l *{2}{D..{3.2}} p{3cm}
if all your tables have a bold left aligned column, two numeric columns and a final column of note paragraphs.
It's hard to guess how you could automate rules in general, If you always want a top and bottom rule you could change your definition to
\newenvironment{mytab}[1][*{50}{c}]{%
\begin{tabular}{#1}\toprule}{%
\\\bottomrule\end{tabular}}
But the position of \midrule
is rather like the position of words and numbers in the table, effectively it's data that must be entered in each case. Perhaps you only want \midrule
after the heading in which case you could use
\newcommand\endhead{\\\midrule}
so your tables would then look like
\begin{mytab}
\hd{type}&\hd{A}&\hd{B}&\hd{Notes}\endhead
zzz&1.2&3.4& zz zz zzzzz\\
zzz&1.2&3.4& zz zz zzzzz\\
\end{tab}
Using a heading command \hd
that could be defined as
\newcommand\hd[1]{%
\multicolumn{1}{c}{\bfseries\begin{tabular}{@{}c@{}}#1\end{tabular}}
To give bold, centred, potentially multi-line table headings. Color could be added to this command as well if you want coloured tables, there is no need for explicit colours in the table.
A solution with Plain TeX for fun, learning, and to show what's possible with the basic building blocks:
\def\widest{000}
\def\uv{\unskip\vrule}
\def\bx#1#2{\vbox{%
\offinterlineskip%
\halign{\ \hfil## &##&\ \hfil## \cr
\hphantom{\widest}&&\hphantom{\widest}\cr
&\vrule\strut& #2\cr
\omit&\hrulefill&\omit\hrulefill\cr
#1&\strut&\cr}
}}
\def\bxx{
\bx{113}{114} &
\bx{99}{100} &
\bx{84}{92} &
\bx{97}{101}\cr
\noalign{\hrule}
}
{\offinterlineskip
\halign{\vrule\strut \hfill #\uv & #\uv & #\uv & #\uv\cr
\noalign{\hrule}
\bxx\bxx\bxx
}}\bye
Best Answer
\centering{OK}
should be{\centering OK\par}
as\centering
does not take an argument, and the end of paragraph needs to be in its scope. that would fix your problem however a more convenient way is to remove all the\centering
from the cells and usewhich inserts the command automatically into each cell, and restores the meaning of
\\
to end a table cell (\centering
defines it to make a centred line break)