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}
Mike Renfro
  • 20,550
and1er
  • 222
  • welcome to tex.se! tabu is nice package, unfortunately it is buggy and no more maintained. – Zarko Aug 18 '17 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 '17 at 14:10

1 Answers1

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

Zarko
  • 296,517
  • 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 '17 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 '17 at 15:34
  • see edit of answer, hopefully now is as you like to have – Zarko Aug 18 '17 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 '17 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 '17 at 08:10
  • ups, by mistace i erase command \ch ... it is quite "sophisticated". ... i will de-erase it :) (soon) – Zarko Aug 19 '17 at 08:34
  • thank you! I could test the solution only on Monday, so that is not urgent) – and1er Aug 19 '17 at 08:37
  • thanks. But I have problems with horizontal alighnment copiling your solution: only second column depends on c in {@{}>{\color{Blue}\bfseries}c@{}}, other header columns are aligned to the left. (I don't know how to attach a figure to a comment). – and1er Aug 21 '17 at 12:32
  • as you see from provided image of provided code compilation, i haven't this problem. i will examine my code again asap. – Zarko Aug 21 '17 at 12:37
  • may this behaviour depend on packages and/or MiKTeX version? – and1er Aug 21 '17 at 12:46
  • it is always good to have recent version of packages, normally they have less bugs (and some times new ones:-( ). i tested my mwe with not recent miktex and work as expected. columns except headers are aligned as determines columns types, column headers are horizontally and vertically centered (in blue color) . – Zarko Aug 21 '17 at 14:57
  • I've installed the latest MiKTeX version and now MWE works as expected. Thank you so much. – and1er Sep 01 '17 at 10:29
  • Sorry, but I mistaken: still I have problems with horizontal alighnment copiling your solution: only second column depends on c. Even if I try to align to the right: {@{}>\color{Blue}\bfseries}r@{}}. – and1er Sep 01 '17 at 12:28
  • i test my solution again (with code copied from my answer) ... and it works as expected. result is as shown in answer. i haven't any idea how you succeed my mwe to not work as expected. you should have something what is hidden to me. i can only suggest you to ask new question, where you show your test mwe and obtained result and clear indication what is not as you expected. maybe someone else will see, what is the problem. – Zarko Sep 01 '17 at 13:36
  • @AndreiLosenkov, sorry for all inconveniences caused by my superficiality in observing of problem, testing of my answer and copying of correct code version of developed solution. – Zarko Sep 06 '17 at 09:45