0

I am making a file in which there are many lines. In every line there is a number. Can I make those numbers decimal alignment?

I am using Latex.

Thanks.

My codes are:

\documentclass[]{article}
\makeatletter
\newcommand\cdotfill{%
    \leavevmode\cleaders\hb@xt@.44em{\hss$\cdot$\hss}\hfill\kern\z@
}
\makeatother
\begin{document}
Car\cdotfill 11111.55 dollar\par
House\cdotfill 2222.1 dollar
\end{document}

I want to make 11111.55 and 2222.1 decimal alignment.

Y. zeng
  • 1,885

1 Answers1

3

enter image description here

\documentclass[]{article}
\makeatletter
\newcommand\cdotfill{%
    \leavevmode\cleaders\hb@xt@.44em{\hss$\cdot$\hss}\hfill\kern\z@
}
\newlength\twodplength
\settowidth\twodplength{.12}
\def\twodp#1{\@twodp#1..\relax}
\def\@twodp#1.#2.#3{%
#1\makebox[\twodplength][l]{\if!#2!\else.#2\fi}}
\makeatother
\begin{document}
Car\cdotfill \twodp{11111.55} dollar\par
House\cdotfill \twodp{2222.1} dollar\par
TeX\cdotfill \twodp{0} dollar\par
\end{document}

This sets everything after the whole number part on a box the width of .12

David Carlisle
  • 757,742