1

I'm trying to use dcolumn for the "percents" column of some survey results, and I'm using the > and < affixes to the column spec to add an opening and closing parenthesis and the percent sign, as the actual data has only the number:

\documentclass{article}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\pagestyle{empty}
\begin{document}
\begin{tabular}{clr>{(}d{1}<{\%)}}\\\hline\vrule height1.2em width0pt
  I&  First& 1&49\\
  II& Second&2&18.5\\
  III&Third& 3&7\\
  IV& Fourth&4&25.5\\\hline
\end{tabular} 
\end{document}

The problem is that the affixes seem to be throwing the spacing off: Example of error without decimal points

If I add a decimal point to the values 49 and 7 (but no fraction part), it fixes the alignment about the decimal, but pushes the column slightly over the RH margin of the table: Example of error with decimal point given

Is there a way around this? The documentation covers most things, but I can't see the way to fix this.

1 Answer 1

1

Perhaps the easiest version is

enter image description here

\documentclass{article}
\usepackage{dcolumn}
\newcolumntype{d}[1]{D{.}{.}{#1}}
\pagestyle{empty}
\begin{document}
\begin{tabular}{@{}clr>{(}d{3.1}@{\%)}}\\\hline\vrule height1.2em width0pt
  I&  First& 1&49\\
  II& Second&2&18.5\\
  III&Third& 3&7\\
  IV& Fourth&4&25.5\\\hline
\end{tabular} 
\end{document}
1
  • I saw that in the doc, but did I try it? Naaaah. Thanks very much! Aug 4, 2016 at 21:52

You must log in to answer this question.

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