0

I am trying to fill a multicolumn cell with \dotfill. For some reason I do not understand, the dots stop too early. (In normal cells it works fine, but multicolumn cells are reacting differently) This is what I get: enter image description here

I had a look at the solution mentioned in this thread but with no success. (the @{} didn't make any difference).

Could someone please help me out filling the multicolumn cells with the \dotfill? Thank you!

Here is my MWE:

\documentclass[11 pt, a4paper, oneside, openany]{book}

\usepackage[table, svgnames]{xcolor}
\usepackage{tabularx}
\usepackage{array}

\begin{document}
\begin{table}[H]
\centering
\begin{tabularx}{\textwidth}{|>{\hsize=1\hsize}X|>{\hsize=1\hsize\arraybackslash}X|}
    \hline
    $\bigcirc$ Aanvraag offerte & $\bigcirc$ Bestelling\\
    \hline
    Offertebon nr.: \dotfill & Bestelbon nr.: \dotfill \\
    \hline
    \multicolumn{2}{|l|}{Firmanaam: \dotfill}\\
    \multicolumn{2}{|l|}{Straat + nr.: \dotfill}\\
    \multicolumn{2}{|l|}{Postcode + Plaats: \dotfill}\\
    \hline      
    Tel.: \dotfill & Fax.: \dotfill \\
    \hline
    \multicolumn{2}{|@{}l|}{Naam aanvrager: \dotfill}\\
    \hline
\end{tabularx}
\end{table}

\begin{table}
\centering
\begin{tabularx}{\textwidth}{|>{\centering\hsize=0.4\hsize}X|>{\centering\hsize=1\hsize}X|>{\centering\hsize=2\hsize}X|>{\centering\hsize=0.6\hsize\arraybackslash}X|}
    \hline
    \rowcolor{SteelBlue} Aantal & Referentiecode & Beschrijving wisselstuk & Levertijd\\
    \hline
    & & &\\
    \hline
    & & &\\
    \hline
    & & &\\
    \hline
    & & &\\
    \hline
    & & &\\
    \hline
    & & &\\
    \hline  
\end{tabularx}
\end{table}
\end{document}
4
  • 1
    If I remove [H] from your example document to make it compilable and then compile, I get the following output that elready seems to be the desired result: i.stack.imgur.com/PMqGw.png
    – leandriis
    Oct 12 '19 at 20:09
  • 1
    No problem either with this code. Unrelated: if both X have the same width, >{\hsize=1\hsize} is totally unnecessary.
    – Bernard
    Oct 12 '19 at 20:19
  • Oh, strange. I got that output with that MWE yesterday. But it seems the compiling files were not up to date and still got older code. I did the update of the MWE and retried. Now I do get the unwanted behaviour... It turns out that the error comes from the simultanously loading of colortbl (via xcolor) and tabularx. Any idea how to fix this?
    – Philippe
    Oct 13 '19 at 8:48
  • @Philippe Yes, colortbl is the culprit.
    – egreg
    Oct 13 '19 at 9:02
0

In order to get the desired output you could either go without colortbl or, if you need this package for a different table in your document, try th following workaround:

enter image description here

\documentclass[11 pt, a4paper, oneside, openany]{book}

\usepackage[table, svgnames]{xcolor}
\usepackage{tabularx}
\usepackage{array}


\usepackage{calc}
\newlength{\mylength}
\setlength{\mylength}{\hsize-2\tabcolsep-4\arrayrulewidth}

\begin{document}
\begin{table}
\centering
\begin{tabularx}{\textwidth}{|X|X|}
    \hline
    $\bigcirc$ Aanvraag offerte & $\bigcirc$ Bestelling\\
    \hline
    Offertebon nr.: \dotfill & Bestelbon nr.: \dotfill \\
    \hline
    \multicolumn{2}{|>{\hsize=\mylength}X|}{Firmanaam: \dotfill}\\
    \multicolumn{2}{|>{\hsize=\mylength}X|}{Straat + nr.: \dotfill}\\
    \multicolumn{2}{|>{\hsize=\mylength}X|}{Postcode + Plaats: \dotfill}\\
    \hline      
    Tel.: \dotfill & Fax.: \dotfill \\
    \hline
    \multicolumn{2}{|>{\hsize=\mylength}X|}{Naam aanvrager: \dotfill}\\
    \hline
\end{tabularx}
\end{table}

\end{document}

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.