1

See the following MWE:

\documentclass[a4paper,DIV=15,oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{amssymb}
\usepackage{ragged2e}
\usepackage{tabularx}

\newcolumntype{D}[1]{>{\Centering}p{#1}}

\begin{document}
\begin{tabular}{|D{5cm}|}
\hline
$\{x\in \mathbb{Q} \, | \, 3{,}8<x<4 \}$\\\hline
$4x+2<5$\\
\hline
\end{tabular}\\[12pt]
$\{x\in \mathbb{Q} \,|\, 3{,}8<x<4 \}$\\[4pt]
$4x+2<5$
\end{document}



enter image description here

As you can see, the gap between the relation sign and the number is increased when I use the new defined columntype (which I need for different reasons). If I use the common p{...} columntype, the gap isn't increased. So, why is the gap increased and how can I avoid it?

1
  • I think you should use a dot for decimals in the input, e.g., 3.8, and then deciding which output you want; that way you leave . for decimals, and , for commas.
    – Manuel
    May 3, 2017 at 20:21

1 Answer 1

2

enter image description here

\Centering unlike the standard \centering uses a finite amount of stretch on the left and right sides. This means that the glue stretching is balanced with interword and math glue stretching.

There are various ways of forcing the math to be set to natural width, for example as here adding an extra {} group as shown in the second table.

\documentclass[a4paper,DIV=15,oneside,12pt]{scrartcl}
\usepackage[ngerman]{babel} 
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage{amssymb}
\usepackage{ragged2e}
\usepackage{tabularx}

\newcolumntype{D}[1]{>{\Centering}p{#1}}

\begin{document}
\begin{tabular}{|D{5cm}|}
\hline
$\{x\in \mathbb{Q} \, | \, 3{,}8<x<4 \}$\\\hline
$4x+2<5$\\
\hline
\end{tabular}


\begin{tabular}{|D{5cm}|}
\hline
${\{x\in \mathbb{Q} \, | \, 3{,}8<x<4 \}}$\\\hline
${4x+2<5}$\\
\hline
\end{tabular}


$\{x\in \mathbb{Q} \,|\, 3{,}8<x<4 \}$\\[4pt]
$4x+2<5$
\end{document}
2
  • Can you name another way of forcing the math to bet set to natural width?
    – Gotti91
    May 3, 2017 at 20:28
  • @Gotti91 you could use \centering you could use \mbox{$...$}outside the math instead of {} inside the math, you could locally (in your definition of the D column) reset \thinmuskip, \medmuskip and \thickmuskip to be fixed lengths without plus/minus components or ... May 3, 2017 at 20:32

You must log in to answer this question.

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