11

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][1]

\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[Boo]
{    }
\date[19.10.12]
{\\ }

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

\begin{document}
\begin{frame}
\begin{center}
\begin{table}
\begin{tabular}{@{}m{\dimexpr.45\textwidth}ccc@{}}
\toprule
procesy & Min & Max  & Else\\
\midrule
Junior         & 1 000 & 2 800 & 4 500\\
\midrule
Senior         &  & ? &\\
\midrule 
Specjalist     &  & ? &\\
\midrule
Team Leader    &  & ? &\\
\bottomrule
\end{tabular}
\caption{1. Caption}
\label{tabela1}
\end{table}
\end{center}
\end{frame}
\end{document}
3
  • 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. Oct 24, 2012 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, 2012 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, 2012 at 21:18

3 Answers 3

12

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

6
  • Great! Gonzalo Medina how to gain more space between text and value [under Min, Max and Dalkia]. Beside that looks like masterpice. Thank You Oct 24, 2012 at 22:29
  • 1
    @DanielMiliński you can add a \strut before "procesy": for example, \multicolumn{2}{@{}l}{\strut procesy}. Oct 24, 2012 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. Oct 24, 2012 at 22:47
  • 1
    @DanielMiliński Ah, sorry! I misunderstood your previous comment. I've updated my answer. Oct 25, 2012 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. Oct 25, 2012 at 3:35
7

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>].

0
0

You can do that with NiceTabular} of nicematrix (≥ 6.6 of 2022-02-16).

\documentclass{beamer}          
\usepackage{nicematrix,tikz,booktabs}

\begin{document}

\begin{frame}
\begin{table}
\NiceMatrixOptions
  {
    custom-line = 
     {
       command = dashedmidrule ,
       tikz = { dashed , color = blue!40 } ,
       width = \pgflinewidth + \aboverulesep + \belowrulesep ,
     }
  }

\begin{NiceTabular}{@{}cX[m]ccc@{}}[rules/color=blue!40]
  \toprule
  \Block[l]{1-2}{procesy} && Min & Max  &Dalkia\\
  \midrule
  & Junior         & 1 700 & 2 800 & 3 200\\
  \dashedmidrule
  & Senior         &  & ? &\\
  \dashedmidrule
  & Specjalist     &  & ? &\\
  \dashedmidrule
  & Team Leader    &  & ? &\\
  \bottomrule
\end{NiceTabular}
\caption{1. Wynagrodzenia: Procesy HR}
\label{tabela1}
\end{table}
\end{frame}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes under the hood).

Output of the above code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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