LaTeX forum ⇒ Graphics, Figures & Tablestable not working with \usepackage[table]{xcolor}

Information and discussion about graphics, figures & tables in LaTeX documents.
marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

table not working with \usepackage[table]{xcolor}

Postby marek_step » Mon Jan 21, 2019 1:28 pm

Hello all!

A funny issue. No idea what's going on here: in the following MWE comment (or out) the \usepackage[table]{xcolor} and the corresponding } marked with a comment. With the colours the numbers are eaten in the resulting pdf ...

Thank you in advance for every hint!

marek

  1. \documentclass[a4paper,landscape]{article}
  2. \usepackage[T1]{fontenc}
  3. \usepackage[utf8]{inputenc}
  4. \usepackage[german]{babel}
  5. \usepackage{bm} % to get bold math symbols
  6. \usepackage[table]{xcolor}
  7. \newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
  8. \usepackage{booktabs}
  9. \usepackage{makecell}
  10. \renewcommand\theadalign{bc}
  11. \renewcommand\theadfont{\bfseries}
  12. \renewcommand\theadgape{\Gape[4pt]}
  13. \renewcommand\cellgape{\Gape[4pt]}
  14. \usepackage[official]{eurosym}
  15.  
  16. \setlength{\parindent}{0em}
  17.  
  18. \begin{document}
  19.  
  20. \begin{table*}\centering
  21. \ra{1.3}
  22. {\rowcolors{2}{green!80!yellow!50}{green!60!yellow!30}
  23. \begin{tabular}{l c r@{ - }l r@{ - }l r@{.}l r@{.}l r@{.}l}
  24. \thead{Flughafen} & \thead{City\\($\bm{\approx{}km$})} & \multicolumn{2}{c}{\thead{Wartezeit\\($\bm{\approx{}Std$})}} & \multicolumn{2}{c}{\thead{Fahrzeit\\($\bm{\approx{}min}$)}} & \multicolumn{2}{c}{\thead{Fahrpreis City\\($\bm{\approx{}}$ \euro{})}} & \multicolumn{2}{c}{\thead{Jahresplakette\\($\bm{\approx{}}$ \euro{})}} & \multicolumn{2}{c}{\thead{Gebühren\\($\bm{\approx{}}$ \euro{})}}\\
  25. \toprule
  26. München & 38 & 3 & 4 & 30 & 60 & 70 & 00 & 360 & 00 & 1 & 50\\ \hline
  27. Frankfurt & 20 & 3 & 5 & 30 & 60 & 2 & 00 & \multicolumn{2}{c}{\o} & 30 & 00\\
  28. \hline
  29. Berlin & 20 & 3 & 5 & 30 & 60 & 2 & 00 & 97 & 00 & 30 & 00\\
  30. \hline
  31. Athen & 20 & 3 & 5 & 30 & 60 & 2 & 00 & 97 & 00 & 30 & 00\\
  32. \hline
  33. Paris 1 (Charles de Gaulle) & 20 & 3 & 5 & 30 & 60 & 50/55 & 00 & 97 & 00 & 30 & 00\\
  34. \hline
  35. Paris 2 (Orly) & 20 & 3 & 5 & 30 & 60 & 30/35 & 00 & 97 & 00 & 30 & 00\\
  36. \hline
  37. London Heathrow & 20 & 3 & 5 & 30 & 60 & 2 & 00 & 97 & 00 & 30 & 00\\
  38. \hline
  39. London Stansted & 20 & 3 & 5 & 30 & 60 & 2 & 00 & 97 & 00 & 30 & 00\\
  40. \hline
  41. London City & 20 & 3 & 5 & 30 & 60 & 2 & 00 & 97 & 00 & 30 & 00\\
  42. \hline
  43. Madrid-Barajas Airport & 20 & 3 & 5 & 30 & 60 & 30 & 00 & 97 & 00 & 30 & 00\\
  44. \hline
  45. Lissabon & 20 & 3 & 5 & 30 & 60 & 2 & 00 & 97 & 00 & 30 & 00\\
  46. \bottomrule
  47. \end{tabular}
  48. } % This is the end } of the table color line above
  49. \caption{Gebühren für Taxiunternehmen und -fahrer an Europäischen Flughäfen}
  50. \end{table*}
  51.  
  52. \end{document}

User avatar
Stefan Kottwitz
Site Admin
Posts: 9406
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Mon Jan 21, 2019 2:40 pm

Hi Marek!

\rowcolors colors the whole row, including the separation space. @{...} is for changing that space, such as by \hspace within, and that should be colored too. Howewer, you use the @{...} syntax for inserting actual text. That's not uncommon, but probably not foreseen with that feature.

In that case I would not use @{...} for inserting dashes or dots. It's probably not the correct spacing around such symbols or relations signs anyway, since it's a tabular intercolumn space and no standard spacing.

I would write the . and - just as usual in the table cell. The alignment may be ok still since the stuff is of the same width. Or one could use dcolumn or siunitx for alignment.

Stefan
Site admin

marek_step
Posts: 27
Joined: Sun Aug 19, 2012 8:48 am

Postby marek_step » Tue Jan 22, 2019 10:51 am

Thank you Stefan for your reply. I will look into the manuals of siunits and dcolumn

Best greetings to all!


marek

User avatar
Stefan Kottwitz
Site Admin
Posts: 9406
Joined: Mon Mar 10, 2008 9:44 pm

Postby Stefan Kottwitz » Tue Jan 22, 2019 11:48 am

By the way, it's siunitx with an x at the end, to distinguish it from the older siunits package. siunitx is the best and modern choice for formatting units. Note, in that example the units are italic, with math font and not proper kerning. Units are commonly written upright. siunitx provides a syntax and does the formatting right. In addition, it provides a table feature with alignment.

Link: http://mirrors.ctan.org/macros/latex/co ... iunitx.pdf

Stefan
Site admin


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests