1

This code is part of a larger file:

\documentclass[11pt,BCOR8mm,final,linktocpage,twoside,open=right,headsepline,a4paper]{scrbook}   
\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[pdftex]{color}
\usepackage[hang,small]{subfigure}
\usepackage[small,bf]{caption}
\usepackage[T1]{fontenc}
\typearea{10}
\usepackage{sidecap}
\usepackage{picins,extpic}
\usepackage{booktabs,colortbl,footmisc}
\usepackage{color,xcolor}
\usepackage{wallpaper}
\usepackage{fancybox}
\usepackage{wallpaper,eso-pic,watermark} 
\usepackage[table]{xcolor}
\usepackage{array}
\usepackage{tabularx,hhline}



\begin{document}



\begin{center}

\begin{table}[htbp]
  \begin{tabularx}{.7\linewidth}{||p{2.363in}*{2}{|r}||}
    \hhline{|t:===:t|}
    \cellcolor{gray!15} \textbf{Lage der Messfl\"ache} & {\cellcolor{gray!15} \textbf{Rechtswert [m]}} & {\cellcolor{gray!15} \textbf{Hochwert [m]}} \\
    \hhline{|:=|=|=:|}
    \cellcolor{gray!15} Das ist ein Test: Was passiert, wenn der Text sehr lange ist?  & 345678.45 & 54346578.88  \\
    \hhline{|b:===:b|}
  \end{tabularx}
\end{table}
\end{center}


\end{document}

The output is:

enter image description here

Two questions: How can I

  • avoid the "X" and "X(0)p"? Both are due tabular.sty (line 119 and 121), I think.

  • align the multiline-text?

Thanks a lot.

4
  • line 119 of tabularx.sty is \@tempdimb\maxdimen why do you think that makes the output you show? Commented Dec 10, 2015 at 19:59
  • In my file the lines 119 - 121 are: \newcolumntype{X}{} \def\tabularxcolumn#1{p{#1}} \def\TX@newcol{\newcol@{X}[0]} so I thought that this could be the cause...
    – Harald
    Commented Dec 10, 2015 at 20:20
  • Don't pass the pdftex option to any package.
    – egreg
    Commented Dec 10, 2015 at 20:48
  • @Harald something is wrong with your file, they are lines 153-156 so your file is corrupted and missing some lines. Commented Dec 10, 2015 at 21:00

1 Answer 1

2

With your MWE I can't reproduce your image (with X above table and X(0)p before table, Table looks OK.

I wondewr, why you use tabularx and than define only p{..}andrtype columns? I sugest you to use onlytabular` width specified columns:

\documentclass[11pt,BCOR8mm,final,linktocpage,twoside,open=right,headsepline,a4paper]{scrbook}
    %\usepackage[ngerman]{babel}
    \usepackage[latin1]{inputenc}
    \usepackage[pdftex]{graphicx}
    %\usepackage[pdftex]{color}% <-- surplus
    \usepackage[hang,small]{subfigure}
    \usepackage[small,bf]{caption}
    %\usepackage[T1]{fontenc}
    \typearea{10}
    %\usepackage{sidecap}
    %\usepackage{picins,extpic}
    \usepackage{booktabs,colortbl,footmisc}
    %\usepackage{color,xcolor} % <-- surplus
    %\usepackage{wallpaper} % <-- surplus
    \usepackage{fancybox}
    %\usepackage{wallpaper,eso-pic,watermark}
    \usepackage[table]{xcolor}
    \usepackage{array}
    \usepackage{tabularx,hhline}
    
        \begin{document}
    \begin{table}[htbp]
    \centering
        \begin{tabular}{||p{2.363in}*{2}{|r}||}
        \hhline{|t:===:t|}
        \cellcolor{gray!15} \textbf{Lage der Messfl\"ache} & {\cellcolor{gray!15} \textbf{Rechtswert [m]}} & {\cellcolor{gray!15} \textbf{Hochwert [m]}} \\
        \hhline{|:=|=|=:|}
        \cellcolor{gray!15} Das ist ein Test: Was passiert, wenn der Text sehr lange ist?  & 345678.45 & 54346578.88  \\
        \hhline{|b:===:b|}
        \end{tabular}
    \end{table}
        \end{document}

which gives:

enter image description here

or use tabularx and replace p{...}widthX`:

\begin{table}[htbp]
\centering
    \begin{tabularx}{0.8\textwidth}{||X*{2}{|r}||}
    \hhline{|t:===:t|}
    \cellcolor{gray!15} \textbf{Lage der Messfl\"ache} & {\cellcolor{gray!15} \textbf{Rechtswert [m]}} & {\cellcolor{gray!15} \textbf{Hochwert [m]}} \\
    \hhline{|:=|=|=:|}
    \cellcolor{gray!15} Das ist ein Test: Was passiert, wenn der Text sehr lange ist?  & 345678.45 & 54346578.88  \\
    \hhline{|b:===:b|}
    \end{tabularx}
\end{table}

In both example I use the same preamble. In it I mark packages, which you load twice (once is enough) and comment those, which I haven't installed and are not influence on table design. In code I replace begin{center} ... \end{center} around table (this is wrong use) width \centering command after \begin{table}.

To my taste, better result you will obtain with the following code:

\documentclass[11pt,BCOR8mm,final,linktocpage,twoside,open=right,headsepline,a4paper]{scrbook}
%\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[hang,small]{subfigure}
\usepackage[small,bf]{caption}
\usepackage[T1]{fontenc}
\typearea{10}
\usepackage{booktabs,colortbl,footmisc}
\usepackage{fancybox}
\usepackage[table]{xcolor}
\usepackage{array,tabularx,hhline}

\usepackage{siunitx}

    \begin{document}
\begin{table}[htbp]
\centering
    \begin{tabularx}{0.85\textwidth}{||>{\raggedright\arraybackslash}X 
                                *{2}{|S[table-format=8.3]}||}
    \hhline{|t:===:t|}
    \cellcolor{gray!15} \textbf{Lage der Messfl\"ache} & {\cellcolor{gray!15} \textbf{Rechtswert [m]}} & {\cellcolor{gray!15} \textbf{Hochwert [m]}} \\
    \hhline{|:=|=|=:|}
    \cellcolor{gray!15} Das ist ein Test: Was passiert, wenn der Text sehr lange ist?  & 345678.45 & 54346578.88  \\
    \hhline{|b:===:b|}
    \end{tabularx}
\end{table}
    \end{document}

which gives:

enter image description here

As you can see, For numbers in last two columns I use S type of column provided by (added) package siunitx.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .