I want to add dots that would fill the space from section/subsection name to the page number in TOC. How do I do that?
Try the tocloft package with something like
in case you're using the
article class (See the package documentation for other classes).
As an illustration, let's try it with the
sample2e.tex file; following
pdflatex sample2e (two times), we got
One way of doing this is to use the memoir class, where this is the default behaviour.
Memoir incorporates an extensive set of functions borged from other useful packages; I use it as my day-to-day general-purpose style for almost everything except presentations.