Fill space with dots within table
I believe that you need only the @{}
separator and p{}
columns with \dotfill
or \hfill
in the cells.
On the other hand, I lost the € symbol with your MWE because the lack of the fontspec
package. For comparison, I included also the eurosym
package for more official symbol (showed in the third column).
%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode
\documentclass[10pt]{article}
\usepackage{fontspec} % needed for the € symbol
\usepackage{eurosym} % another way to obtain the € symbol
\usepackage{booktabs}
\begin{document}
\begin{table}[!htbp]
\begin{tabular}{p{.4\textwidth}@{}p{.2\textwidth}@{}p{.2\textwidth}@{}}
\toprule
Anzahl \hfill Behandlungstyp & \hfill Einzelpreis & \hfill Gesamtpreis\\
\midrule
10\dotfill Manuelle Therapie & \dotfill\euro32,63 & \dotfill€326,30\\
10\dotfill Krankengymastik & \dotfill\euro26,93 &\dotfill€269,30\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
This is an ugly hack
\documentclass[10pt]{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[!htbp]
\begin{tabular}{l@{}r@{}lr}
\toprule
Anzahl \quad
& \multicolumn{1}{r@{}}{\hspace{1cm}Behandlungstyp}\quad
& Einzelpreis
& Gesamtpreis\\
\midrule
10\dotfill
& Manuelle Therapie\dotfill
&\multicolumn{2}{@{}c}{€32,63\dotfill €326,30}\\
%%
10\dotfill
& Krankengymastik\dotfill
&\multicolumn{2}{@{}c}{€26,93\dotfill €269,30}\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
For the alignment as requested in the comment
\begin{tabular}{lcr@{}r@{}r}
\toprule
Anzahl
&
& Behandlungstyp
& \multicolumn{1}{@{\hspace{1em}}r@{}}{Einzelpreis}
& \multicolumn{1}{@{\hspace{1em}}r}{Gesamtpreis}\\
\midrule
\multicolumn{3}{c@{}}{10\dotfill Manuelle Therapie}
& \dotfill 32,63
& \dotfill 326,30\\
%%
\multicolumn{3}{c@{}}{10\dotfill Krankengymastik}
& \dotfill 26,93
& \dotfill 269,30\\
\bottomrule
\end{tabular}
Here are two options:
Manual using box length calculations:
\documentclass{article} \usepackage{booktabs}% http://ctan.org/pkg/booktabs \newlength{\tmplenA}\newlength{\tmplenB} \begin{document} \begin{tabular}{lrrr} \toprule Anzahl & Behandlungstyp & Einzelpreis & Gesamtpreis\\ \midrule \settowidth{\tmplenA}{Anzahl}\settowidth{\tmplenB}{10}\addtolength{\tmplenA}{-\tmplenB}% 10\rlap{\makebox[\dimexpr\tmplenA+2\tabcolsep][l]{\dotfill}} & Manuelle Therapie & \settowidth{\tmplenA}{Einzelpreis}\settowidth{\tmplenB}{€32,63}\addtolength{\tmplenA}{-\tmplenB}% \llap{\makebox[\dimexpr\tmplenA+2\tabcolsep][r]{\dotfill}}€32,63 & \settowidth{\tmplenA}{Gesamtpreis}\settowidth{\tmplenB}{€326,30}\addtolength{\tmplenA}{-\tmplenB}% \llap{\makebox[\dimexpr\tmplenA+2\tabcolsep][r]{\dotfill}}€326,30 \\ \settowidth{\tmplenA}{Anzahl}\settowidth{\tmplenB}{10}\addtolength{\tmplenA}{-\tmplenB}% \settowidth{\tmplenB}{Manuelle Therapie}\addtolength{\tmplenA}{\tmplenB}% \settowidth{\tmplenB}{Krankengymastik}\addtolength{\tmplenA}{-\tmplenB}% 10\rlap{\makebox[\dimexpr\tmplenA+2\tabcolsep][l]{\dotfill}} & Krankengymastik & \settowidth{\tmplenA}{Einzelpreis}\settowidth{\tmplenB}{€26,93}\addtolength{\tmplenA}{-\tmplenB}% \llap{\makebox[\dimexpr\tmplenA+2\tabcolsep][r]{\dotfill}}€26,93 & \settowidth{\tmplenA}{Gesamtpreis}\settowidth{\tmplenB}{€269,30}\addtolength{\tmplenA}{-\tmplenB}% \llap{\makebox[\dimexpr\tmplenA+2\tabcolsep][r]{\dotfill}}€269,30\\ \bottomrule \end{tabular} \end{document}
Overwriting a
\dotfill
spanning the entiretabular
width with white-background-boxed entries:\documentclass{article} \usepackage{booktabs}% http://ctan.org/pkg/booktabs \usepackage{xcolor}% http://ctan.org/pkg/xcolor \usepackage{array}% http://ctan.org/pkg/array \makeatletter \newcolumntype{L}{>{\begin{lrbox}{\@tempboxa}}l<{\end{lrbox}\colorbox{white}{\usebox{\@tempboxa}}}} \newcolumntype{R}{>{\begin{lrbox}{\@tempboxa}}r<{\end{lrbox}\colorbox{white}{\usebox{\@tempboxa}}}} \makeatother \newlength{\tmplenA} \setlength{\fboxrule}{0pt}\setlength{\fboxsep}{0pt} \begin{document} \settowidth{\tmplenA}{AnzahlManuelleTherapieEinzelpreisGesamtpreis\hspace*{6\tabcolsep}} \begin{tabular}{LRRR} \toprule Anzahl & Behandlungstyp & Einzelpreis & Gesamtpreis\\ \midrule \rlap{\makebox[\tmplenA][l]{\dotfill}}\colorbox{white}{10} & Manuelle Therapie & €32,63 & €326,30 \\ \rlap{\makebox[\tmplenA][l]{\dotfill}}\colorbox{white}{10} & Krankengymastik & €26,93 & €269,30\\ \bottomrule \end{tabular} \end{document}
Here's the output of both: