Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In my table I use different combinations of a checkmark standing alone, in parentheses, or with an asterisk. I would like to have a centered column in which the checkmarks align.

By using the package dcolumn and defining the checkmark as decimal point I get the desired alignment. However, when running this through pdfLaTeX I encounter two problems:

  1. \ding{51} is not printed correctly even though I loaded the package pifont.
  2. The column is not center aligned anymore.

Why does this happen and how can I get the desired result?

\documentclass[a5paper, 11pt]{scrbook}

\usepackage{pifont}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{A}{D{.}{\ding{51}}{-1}}

\begin{document}

\begin{table}
\centering
 \begin{tabularx}{\textwidth}{Xc}
 \textbf{Element} & \textbf{Availability}\\
 \midrule
 Some Element & \ding{51}\\ 
 Another Element & \ding{51}\textsuperscript{\textasteriskcentered}\\
 Yet Another Element & (\ding{51})\\
 One More Element & (\ding{51}\textsuperscript{\textasteriskcentered})\\
 \end{tabularx}
\caption{Unaligned example table}
\end{table}

\begin{table}
\centering
 \begin{tabularx}{\textwidth}{XA}
 \textbf{Element} & \textbf{Availability}\\
 \midrule
 Some Element & .\\
 Another Element & .\textsuperscript{\textasteriskcentered}\\
 Yet Another Element & (.)\\
 One More Element & (.\textsuperscript{\textasteriskcentered})\\
 \end{tabularx}
\caption{Aligned example table, but with problems displaying the checkmark and messed up centering.}
\end{table}

\end{document}
share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

The problem is that columns of type D from the dcolumn package always use math mode, and \ding{51} in math mode is printed as 3.

So, you can force its contents to be in text mode, substituting the line

\newcolumntype{A}{D{.}{\ding{51}}{-1}}

with

\newcolumntype{A}{D{.}{\textrm{\ding{51}}}{-1}}

Note that, for the same reason, you can substitute \textsuperscript{\textasteriskcentered} with ^*

To keep the first line centered use \multicolumn, otherwise it will check for the alignment point.

MWE:

\documentclass[a5paper, 11pt]{scrbook}

\usepackage{pifont}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{dcolumn}
\newcolumntype{A}{D{.}{\textrm{\ding{51}}}{-1}}

\begin{document}

\begin{table}
\centering
 \begin{tabularx}{\textwidth}{Xc}
 \textbf{Element} & \textbf{Availability}\\
 \midrule
 Some Element & \ding{51}\\
 Another Element & \ding{51}\textsuperscript{\textasteriskcentered}\\
 Yet Another Element & (\ding{51})\\
 One More Element & (\ding{51}\textsuperscript{\textasteriskcentered})\\
 \end{tabularx}
\caption{Unaligned example table}
\end{table}

\begin{table}
\centering
 \begin{tabularx}{\textwidth}{XA}
 \textbf{Element} & \multicolumn{1}{c}{\textbf{Availability}}\\
 \midrule
 Some Element & .\\
 Another Element & .^*\\
 Yet Another Element & (.)\\
 One More Element & (.^*)\\
 \end{tabularx}
\caption{Aligned example table, but with problems displaying the checkmark and messed up centering.}
\end{table}

\end{document} 

Output:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.