[Tex/LaTex] vertical alignment using tabularx / arraystretch

tablestabularxvertical alignment

I am using the tabularx package to customize my tables. I changed the definition of tabularxcolumn to vertically center the text. As I am using arraystretch, the bold 'titles' of my table are aligned quite ugly. How can I fix this?

  \documentclass[fleqn,10pt,twocolumn]{article} % Document font size and equations 
  \usepackage{tabularx}
  \usepackage[table]{xcolor}
  \usepackage{colortbl}
  \usepackage{enumitem}
  \renewcommand\tabularxcolumn[1]{m{#1}}
  \renewcommand\arraystretch{1.5} \setlength\minrowclearance{2.4pt} 

  \arrayrulecolor{blue}

  \newcolumntype{=}{>{\global\let\currentrowstyle\relax}}
  \newcolumntype{^}{>{\currentrowstyle}}
  \newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
    #1\ignorespaces
  }


  \begin{document}
  \begin{tabularx}{\linewidth}{|=l^X|@{}}
  \multicolumn{2}{>{\columncolor{blue}}c}{\color{white}\textbf{Table: Interfaces}} \\
  \hline
  \rowcolor{blue}
  \rowstyle{\color{white}\bfseries}
  \textbf{Interface} &\rowstyle{\color{white}}\textbf{Programming Languages}\\
  \texttt{.NET}
   & The blablab this is only some text to illustrate my problem:
   \begin{itemize}[topsep=-5pt,leftmargin=0.7cm,itemsep=0.8pt,labelsep=.5cm]
   \item C\#
   \item VB .NET
   \end{itemize}\\
  \texttt{JNI}
  & Some other text \\
   \hline
  \end{tabularx}
  \end{document}

And can someone explain when I need to insert this @{}? I still dont get that..

Best Answer

enter image description here

You had

Overfull \hbox (10.00002pt too wide) in paragraph at lines 34--35

As your table was full width but indented by paragraph indent (10pt) I added \noindent.

You do not have to use @{} ever but if you do use it (or |) you need to be consistent. | adds a rule and @{} removes the usual inter-column padding which by default also appears before the first and after the last column. If you use these you need to use them also in the \multicolumn specifications so that the spanning columns get the same inter-column space as the columns they span.

(update Note the use of an l cell to ensure baseline alignment of the headings)

It's a bit unusual to put Table:.. in the table rather than have a separate caption, but I left it like that:

 \documentclass[fleqn,10pt,twocolumn]{article} % Document font size and equations 
  \usepackage{tabularx}
  \usepackage[table]{xcolor}
  \usepackage{colortbl}
  \usepackage{enumitem}
  \renewcommand\tabularxcolumn[1]{m{#1}}
  \renewcommand\arraystretch{1.5} \setlength\minrowclearance{2.4pt} 

  \arrayrulecolor{blue}

  \newcolumntype{=}{>{\global\let\currentrowstyle\relax}}
  \newcolumntype{^}{>{\currentrowstyle}}
  \newcommand{\rowstyle}[1]{\gdef\currentrowstyle{#1}%
    #1\ignorespaces
  }


  \begin{document}

  \noindent X\dotfill X

  \noindent
  \begin{tabularx}{\linewidth}{@{}|=l^X|@{}}
  \multicolumn{2}{@{}|>{\columncolor{blue}}c|@{}}{\color{white}\textbf{Table: Interfaces}} \\
  \hline
  \rowcolor{blue}
  \rowstyle{\color{white}\bfseries}
  \textbf{Interface} &\multicolumn{1}{l|@{}}{\textcolor{white}{\textbf{Programming Languages}}}\\
  \texttt{.NET}
   & The blablab this is only some text to illustrate my problem:
   \begin{itemize}[topsep=-5pt,leftmargin=0.7cm,itemsep=0.8pt,labelsep=.5cm]
   \item C\#
   \item VB .NET
   \end{itemize}\\
  \texttt{JNI}
  & Some other text \\
   \hline
  \end{tabularx}
  \end{document}