3

I am trying to make some LaTeX templates for my company and I got stuck on tabu vertical alignment. I have tried many versions, but still cannot get through this problem. Could anyone help me solving this issue please? I simply want to have all text vertically aligned to the center. Here is my code

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[default]{opensans}
\usepackage{geometry}
\geometry{a4paper}
\usepackage[czech]{babel}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{ifthen}
\usepackage{array}
\usepackage{tabu}
\usepackage{colortbl}
\usepackage{arydshln}
\usepackage[overload]{ragged2e}
%colors
\definecolor{tablegreylinebg}{RGB}{119, 119, 119}
\definecolor{tablegreylinetext}{RGB}{255, 255, 255}
%tables
\def\arraystretch{1.5} 
\setlength\dashlinedash{0.5pt}
\setlength\dashlinegap{2.5pt}
\setlength\arrayrulewidth{0.3pt}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newenvironment{mytable}[2]
    {\begin{tabu} to \textwidth {L{#1cm} X[l] R{#2cm}}}
    {\end{tabu}
}
\newcommand{\addgrey}[2]{
    \multicolumn{2}{l}{\cellcolor{tablegreylinebg}\fontsize{14}{11}\selectfont\color{tablegreylinetext}\textbf{\uppercase{#1}}} & \cellcolor{tablegreylinebg}\fontsize{14}{11}\selectfont\color{tablegreylinetext}\textbf{#2} \\[0.2ex]
}
\newcommand{\addnormal}[3]{
     \textbf{#1} & \textit{#2} &  \textbf{#3} \\
}
%document starts here
\begin{document}
    \begin{mytable}{2.7}{4.5}
        \addgrey{servisní smlouva exclusive}{3000 Kč / měsíc}
        \addnormal{reakční doba}{do \color{red}1 hodiny \color{black}od nahlášení chyby či požadavku}{}
        \hdashline
        \addnormal{hodinová sazba}{za programátorské práce a drobné grafické úpravy}{\color{red}300 Kč}
        \hdashline
        \addnormal{redakční systém Ereso}{jednorázové školení používání redakčního systému u Vás na pracovišti}{zdarma}
        \hdashline
        \addnormal{reporty}{měsíční reporty návštěvnosti Vaší internetové prezentace}{zdarma}
        \hdashline
        \addnormal{zahrnuté hodiny}{v ceně servisní smlouvy za programátorské práce každý měsíc}{\color{red}6}  
    \end{mytable}
\end{document}

And here is how the table looks printed with pdfLaTeX

enter image description here

1
  • thx for edit, I am new here
    – Jarda
    Dec 14, 2014 at 14:06

1 Answer 1

2

You omitted the vertical alignment specifier for the middle column:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[default]{opensans}
\usepackage{geometry}
\geometry{a4paper}
\usepackage[czech]{babel}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{ifthen}
\usepackage{array}
\usepackage{tabu}
\usepackage{colortbl}
\usepackage{arydshln}
\usepackage[overload]{ragged2e}
%colors
\definecolor{tablegreylinebg}{RGB}{119, 119, 119}
\definecolor{tablegreylinetext}{RGB}{255, 255, 255}
%tables
\def\arraystretch{1.5} 
\setlength\dashlinedash{0.5pt}
\setlength\dashlinegap{2.5pt}
\setlength\arrayrulewidth{0.3pt}
\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newenvironment{mytable}[2]
    {\begin{tabu} to \textwidth {L{#1cm} X[l,m] R{#2cm}}}
    {\end{tabu}
}
\newcommand{\addgrey}[2]{
    \multicolumn{2}{l}{\cellcolor{tablegreylinebg}\fontsize{14}{11}\selectfont\color{tablegreylinetext}\textbf{\uppercase{#1}}} & \cellcolor{tablegreylinebg}\fontsize{14}{11}\selectfont\color{tablegreylinetext}\textbf{#2} \\[0.2ex]
}
\newcommand{\addnormal}[3]{
     \textbf{#1} & \textit{#2} &  \textbf{#3} \\
}
%document starts here
\begin{document}
    \begin{mytable}{2.7}{4.5}
        \addgrey{servisní smlouva exclusive}{3000 Kč / měsíc}
        \addnormal{reakční doba}{do \color{red}1 hodiny \color{black}od nahlášení chyby či požadavku}{}
        \hdashline
        \addnormal{hodinová sazba}{za programátorské práce a drobné grafické úpravy}{\color{red}300 Kč}
        \hdashline
        \addnormal{redakční systém Ereso}{jednorázové školení používání redakčního systému u Vás na pracovišti}{zdarma}
        \hdashline
        \addnormal{reporty}{měsíční reporty návštěvnosti Vaší internetové prezentace}{zdarma}
        \hdashline
        \addnormal{zahrnuté hodiny}{v ceně servisní smlouvy za programátorské práce každý měsíc}{\color{red}6}  
    \end{mytable}
\end{document}
1
  • It is better, but still the text "3000 Kč / měsíc" is verticalloy aligned to the top of the cell - it does not look good
    – Jarda
    Dec 14, 2014 at 23:10

You must log in to answer this question.

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