3

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}
2
  • welcome to tex.se! tabu is nice package, unfortunately it is buggy and no more maintained.
    – Zarko
    Aug 18, 2017 at 14:07
  • Thank you, @Zarko. If tabu is not actual now, which if existing table packaged is powerful enough to substitute tabu?
    – and1er
    Aug 18, 2017 at 14:10

1 Answer 1

1

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

15
  • Thank you for answer. I'm agree that \color should be replaced as you wrote. It is not a problem to color each head cell text using your solution. But this solution doesn't make the head text vertically center aligned as I see.
    – and1er
    Aug 18, 2017 at 14:39
  • BTW. If tabu is obsolete and is not consistent maybe you know any other package to substitute tabu? We need following features: - X-type columns (auto width for specified size) with ability to adjust horizontal and vertical alignment for whole column, and in the same time text wrap, padding control, text and figures positioning (tabularx for example has X width columns but it don't know how to satisfy other mentioned style)
    – and1er
    Aug 18, 2017 at 15:34
  • see edit of answer, hopefully now is as you like to have
    – Zarko
    Aug 18, 2017 at 15:37
  • as you mentioned: tabularx, but missing features you have to add with some other package. for examples: for figures is handy [export]{adjustbox}, for vertical align only in some rows on the way as i do in above answer, etc.
    – Zarko
    Aug 18, 2017 at 15:42
  • yes, the figure of your result now shows exactly what I need. But I cannot find \ch{} command definition in your MWE. I suppose it is something like \newcommand{\ch}[1]{\textcolor{\textbf{#1}}}, but how does vertical alignment is inplement?
    – and1er
    Aug 19, 2017 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .