[Tex/LaTex] Tabu table text-colored header: vertical and horizontal alignment, one line and word wrap cases

colorhorizontal alignmenttablestabuvertical alignment

We have a latex tabu table with custom header's style: it has different alignment, color and shape from other table rows.

BTW XeLaTeX is used.

Header could be short on length, see the pictures and minimal working example (MWE, in the end).

It is neccesarry to apply following style to header text:

  • bold;
  • aligned to horizontal center;
  • aligned to vertical center (both for one line or word wrapped cases);
  • custom color is #0070C0;

Desired result

Desired

We have applied \rowfont{} command to the first tabu table row as in answer https://tex.stackexchange.com/a/26363/123948

\taburulecolor{DarkBlue}
\tabulinesep = 1mm
\begin{tabu} to 170 mm {
    |X[2]       %  |X[2,m]
    |X[1.5]     %  |X[1.5,m]
    |X[0.6, C]  %  |X[0.6, C,m]
    |X[2]       %  |X[2,m]
    |X[0.6, C]| %  |X[0.6, C,m]|
    }
\rowfont{\centering\bfseries\color{Blue}}
%...

and:

  • text became bold using \bfseries;
  • aligned to horizontal center using \centering;
  • color is \definecolor{Blue}{HTML}{1C8CCC};
  • tried tabu's m colunm type to align to vertical center, but it works only in wrapped case (one-line is not) and it affects to whole table, but we need header only.

Actual result
without m type because it affects to the whole table

actual

Questions

  • How to align vertically only header text using \rowfont{} (or other way)?
  • Are horizontal alignment and coloring of header row implemented correctly or there are better ways?

Minimal working example

XeLaTeX is used.

\documentclass[10pt, oneside, a4paper]{report}
\usepackage[left=2cm,right=1.5cm,
    top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{indentfirst} 
\usepackage{titlesec}
\usepackage{tabu}
\usepackage[svgnames]{xcolor}
\definecolor{DarkBlue}{HTML}{0070C0} 
\definecolor{Blue}{HTML}{1C8CCC} 
\usepackage{multirow}
\usepackage{polyglossia}
\setmainfont[Ligatures=TeX]{Arial}


%--------------------------------------------
\begin{document}

\taburulecolor{DarkBlue}
\tabulinesep = 1mm
\begin{tabu} to 170 mm {
    |X[2]       %  |X[2,m]
    |X[1.5]     %  |X[1.5,m]
    |X[0.6, C]  %  |X[0.6, C,m]
    |X[2]       %  |X[2,m]
    |X[0.6, C]| %  |X[0.6, C,m]|
    }
\rowfont{\centering\bfseries\color{Blue}}

\hline

Status
    & Visual indication: color and indication type %% WORD WRAP
%        & Visual indication %% one line
    & Symbol
    & Audible signal
    & Priority\\ \hline

Alarm active, not acknowledge 
    & Red, blinking 
    & picture
    & Accompanied by an audible signal, as 3 short audible signals repeated every 7 s
    & High 
    \\ \hline

Alarm active, silenced 
    & Red, blinking 
    & picture
    & Silent 
    & 
    \\ \hline
\end{tabu}
\end{document}

Best Answer

Edit:

  • tabu is nice package, reach of features but unfortunately it is buggy and no more maintained.
  • problem is in use color{...} (independent of used latex engine)
  • as workaround see if the following solution is acceptable for you
    • remove \rowcolor{...}
    • define new commanad (see mwe below, let its name be \ch (column header) which carry about boldface font, color of fonts and vertical spacing of cells content

\documentclass[10pt, oneside, a4paper]{report}
\usepackage[left=2cm,right=1.5cm,
    top=2cm,bottom=2cm,bindingoffset=0cm]{geometry}
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{tabu}
\usepackage[svgnames]{xcolor}
\definecolor{DarkBlue}{HTML}{0070C0}
\definecolor{Blue}{HTML}{1C8CCC}
\usepackage{multirow}
%\usepackage{polyglossia} % i haven't this fonts
%\setmainfont[Ligatures=TeX]{Arial}% i haven't this fonts

\newcommand\ch[1]{\centering                        % <--- added
    \begin{tabular}{@{}>{\color{Blue}\bfseries}c@{}}
                    #1
    \end{tabular}
                  }

\begin{document}
\taburulecolor{DarkBlue}
\tabulinesep=1mm       
\begin{tabu} to 170 mm {
    |X[2]       %  |X[2,m]
    |X[1.5]     %  |X[1.5,m]
    |X[0.6, C]  %  |X[0.6, C,m]
    |X[2]       %  |X[2,m]
    |X[0.6, C]| %  |X[0.6, C,m]|
    }
\hline
\ch{Status}
    & \ch{Visual indication:\\ color and\\ indication type}
    & \ch{Symbol}
    & \ch{Audible signal}
    & \ch{Priority}\\ \hline   

Alarm active, not acknowledge
    & Red, blinking
    & picture
    & Accompanied by an audible signal, as 3 short audible signals repeated every 7 s
    & High
    \\ \hline    
Alarm active, silenced
    & Red, blinking
    & picture
    & Silent
    &
    \\ \hline
\end{tabu}
\end{document}

enter image description here