Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is it possible to make two \midrules in one booktab? The first one should be colored, the second one colored and dashed, as it is shown in the picture. Before each entry is a horizontal space - how to include such space in my table?

output as it should be

\documentclass{beamer}          

\mode<presentation>
{   \usetheme{Madrid}
    \setbeamercovered{transparent}
}

\usepackage{booktabs}

\usepackage{amsmath}
\usepackage{amsfonts}
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}

\usepackage[utf8x]{inputenc}
\usepackage[MeX]{polski}

\usepackage{tabularx}
\usepackage{color}
\usepackage{graphicx}

\usepackage[utopia]{mathdesign}

\usecolortheme{crane}

\renewcommand\figurename{Rys.}
\def\captionlabeldelim{.}

\renewcommand\tablename{Tab.}
\def\captionlabeldelim{.}
\usepackage[small,bf,singlelinecheck=off]{caption}

\title[Midrule]
{\textbf{midrule}\\ colored and dashed}
\subtitle{}
\author[]{No name}
\institute[Misiu]
{    }
\date[19.10.12]
{\\ Warszawa, 22. października 2012r.}

\subject{Wynagrodzenia}
\AtBeginSection[]
{ \begin{frame}<beamer>
   \frametitle{Plan prezentacji}
   \tableofcontents[currentsection]
  \end{frame}
}

\begin{document}
\begin{frame}
\begin{center}
\begin{table}
\begin{tabular}{@{}m{\dimexpr.45\textwidth}ccc@{}}
\toprule
procesy & Min & Max  &Dalkia\\
\midrule
Junior         & 1 700 & 2 800 & 3 200\\
\midrule
Senior         &  & ? &\\
\midrule 
Specjalist     &  & ? &\\
\midrule
Team Leader    &  & ? &\\
\bottomrule
\end{tabular}
\caption{1. Wynagrodzenia: Procesy HR}
\label{tabela1}
\end{table}
\end{center}
\end{frame}
\end{document}
share|improve this question
1  
To get the leading space you could either insert an \hspace*{<len>}, or add a leading column and use \multicolumn{2}{l}{procesy} for the title row so that it spans the first two columns. And add a leading & for the subsequent rows. –  Peter Grill Oct 24 '12 at 19:18
1  
Well, are you sure that your minimal working example (MWE) is really minimal? BTW: I suggest using \centering instead of the center environment. –  Stephen Oct 24 '12 at 19:23
    
Why not avoiding altogether the horizontal rules you want to be dashed? It's a table and it's natural to read it by rows. –  egreg Oct 24 '12 at 21:18
add comment

2 Answers

up vote 9 down vote accepted

You can use the tabu package instead:

\documentclass{beamer}          
\usepackage{tabu}

\begin{document}

\begin{frame}
\begin{table}
\tabulinesep =_4pt^4pt
\begin{tabu}to \textwidth{@{}cX[m]ccc@{}}
  \tabucline[1pt blue!40 off 0pt]{-}
  \multicolumn{2}{@{}l}{procesy} & Min & Max  &Dalkia\\
  \tabucline[0.7pt blue!40 off 0pt]{-}
  & Junior         & 1 700 & 2 800 & 3 200\\
  \tabucline[0.4pt blue!40 off 2pt]{-}
  & Senior         &  & ? &\\
  \tabucline[0.4pt blue!40 off 2pt]{-}
  & Specjalist     &  & ? &\\
  \tabucline[0.4pt blue!40 off 2pt]{-}
  & Team Leader    &  & ? &\\
  \tabucline[1pt blue!40 off 0pt]{-}
\end{tabu}
\caption{1. Wynagrodzenia: Procesy HR}
\label{tabela1}
\end{table}
\end{frame}

\end{document}

enter image description here

share|improve this answer
    
Great! Gonzalo Medina how to gain more space between text and value [under Min, Max and Dalkia]. Beside that looks like masterpice. Thank You –  Daniel Miliński Oct 24 '12 at 22:29
1  
@DanielMiliński you can add a \strut before "procesy": for example, \multicolumn{2}{@{}l}{\strut procesy}. –  Gonzalo Medina Oct 24 '12 at 22:39
    
Still, it dosen't work. Text inside table is to close to numbers. My goal is to get "Min", "Max", "Dalkia" on the left side [as close as possible] and get more space for text on right side. –  Daniel Miliński Oct 24 '12 at 22:47
1  
@DanielMiliński Ah, sorry! I misunderstood your previous comment. I've updated my answer. –  Gonzalo Medina Oct 25 '12 at 3:28
1  
@azetina booktabs doesn't offer built-in dashed lines; one could do some work to get them, but I don't think it's worth, specially if tabu offers them ready to use. –  Gonzalo Medina Oct 25 '12 at 3:35
show 2 more comments

Here is an option that compares the tabu output of Gonzalo's answer with that of booktabs. It's workable in comparison with tabu, but it's not always pretty.

enter image description here

\documentclass{article}          
\usepackage{tabu}% http://ctan.org/pkg/tabu
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{booktabs}% http://ctan.org/pkg/booktabs
\makeatletter
\newcommand{\dashrule}[1][black]{%
  \color{#1}\rule[\dimexpr.5ex-.2pt]{4pt}{.4pt}\xleaders\hbox{\rule{4pt}{0pt}\rule[\dimexpr.5ex-.2pt]{4pt}{.4pt}}\hfill\kern0pt%
}
\newcommand{\rulecolor}[1]{%
  \def\CT@arc@{\color{#1}}%
}
\makeatother
\begin{document}

\begin{table}[t]
\tabulinesep =_4pt^4pt
\begin{tabu}to \textwidth{@{}cX[m]X[c]X[c]X[c]@{}}
  \tabucline[1pt blue!40 off 0pt]{-}
  \multicolumn{2}{@{}l}{procesy} & Min & Max  &Dalkia\\
  \tabucline[0.7pt blue!40 off 0pt]{-}
  & Junior         & 1 700 & 2 800 & 3 200\\
  \tabucline[0.4pt blue!40 off 2pt]{-}
  & Senior         &  & ? &\\
  \tabucline[0.4pt blue!40 off 2pt]{-}
  & Specjalist     &  & ? &\\
  \tabucline[0.4pt blue!40 off 2pt]{-}
  & Team Leader    &  & ? &\\
  \tabucline[1pt blue!40 off 0pt]{-}
\end{tabu}

\bigskip

\rulecolor{blue!40}
\begin{tabularx}{\linewidth}{X>{\centering}X>{\centering}X>{\centering\arraybackslash}X@{}}
  \toprule
  procesy & Min & Max & Delta \\
  \midrule
  Junior & 1\,700 & 2\,800 & 3\,200 \\[-\jot]
  \multicolumn{4}{@{}c@{}}{\makebox[\linewidth]{\dashrule[blue!40]}} \\[-\jot]
  Senior         &  & ? &\\
  \multicolumn{4}{@{}c@{}}{\makebox[\linewidth]{\dashrule[blue!40]}} \\[-\jot]
  Specjalist     &  & ? &\\
  \multicolumn{4}{@{}c@{}}{\makebox[\linewidth]{\dashrule[blue!40]}} \\[-\jot]
  Team Leader    &  & ? &\\
  \bottomrule
\end{tabularx}
\caption{1. Wynagrodzenia: Procesy HR}
\end{table}

\end{document}

The use of tabularx makes it convenient to specify the tabular width. Rule colour is specified using \rulecolor{<color>} and that of the dashed rule is done using \dashrule[<color>].

share|improve this answer
    
For me - Looks very good. Thank You Werner! –  Daniel Miliński Oct 25 '12 at 9:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.